Re: Using NSFileHandleConnectionAcceptedNotification for a server process
Re: Using NSFileHandleConnectionAcceptedNotification for a server process
- Subject: Re: Using NSFileHandleConnectionAcceptedNotification for a server process
- From: Jens Alfke <email@hidden>
- Date: Sat, 9 Feb 2008 16:14:22 -0800
On 8 Feb '08, at 5:14 PM, Matt Mashyna wrote:
Well, I guess I was stuck on the idea that my problem was really
that I needed to increase the fd buffer so I would get the whole
chunk of data at one time but maybe I'm not thinking about it in the
right way.
I think you could get that effect by calling -
readToEndOfFileInBackgroundAndNotify instead; but I've never tried
that. In generally it's better to read the data in chunks, as that way
you can provide progress feedback to the user. It also avoids loading
all of the data into memory at once.
I can re-register for more data but then it's not clear to me how I
know that the client is done sending it's stream and waiting for a
reply. There doesn't seem to be a NSFileHandle method to see if more
data is waiting to be read. I know I'm being dense. I just need a
slap!
IIRC, what happens at EOF is that you get a notification whose NSData
payload is either zero bytes long or nil (not sure which). So the
logic is that, if you received at least one byte of data, you call -
readInBackgroundAndNotify again, else you know you're done.
Don't feel bad about being confused about this. The docs are pretty
vague, and I got really confused when I was first trying to use
NSFileHandle too.
—Jens_______________________________________________
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