RE: NSInputStream Not Reading All Data
RE: NSInputStream Not Reading All Data
- Subject: RE: NSInputStream Not Reading All Data
- From: "Gary L. Wade" <email@hidden>
- Date: Thu, 23 Oct 2008 17:22:07 -0400
I use different APIs, but I just read until I get a 0 or -1 back for the length.
>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