NSInputStream Not Reading All Data
NSInputStream Not Reading All Data
- Subject: NSInputStream Not Reading All Data
- From: Thaddeus Cooper <email@hidden>
- Date: Thu, 23 Oct 2008 11:37:27 -0700
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