Re: NSInputStream Not Reading All Data
Re: NSInputStream Not Reading All Data
- Subject: Re: NSInputStream Not Reading All Data
- From: Roland King <email@hidden>
- Date: Fri, 24 Oct 2008 06:56:11 +0800
are you sure the data is being sent? What's on the other end sending
it, is it buffering data and not sending the last 216 bytes?
On Oct 24, 2008, at 2:37 AM, Thaddeus Cooper wrote:
Hi All.
I have an NSInputStream that I've set up on the run loop to read
data from a socket. It's mostly working except that when I am
sending it a large amount of data (say 30k), the last chunk of data
never shows up. I have tried reading 1 byte, 10 bytes and 1024 bytes
in the handleStream method and the last 216 bytes never show up.
I've looked in the archives and noticed that 3 years ago someone
else had a similar problem -- but there was no followup.
The question I have is what do I need to do to get the last chunk of
data off the stream. Below is a snippet of the code I'm using to
read data off the stream inside handleEvent.
Thanks very much.
Thaddeus O. Cooper
(email@hidden)
while ([_inStream hasBytesAvailable]) {
len = [(NSInputStream *)stream read:buf maxLength:1024];
[data appendBytes:(const void *)buf length:len];
bytesRead = bytesRead + len;
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden