• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Using NSFileHandleConnectionAcceptedNotification for a server process
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Using NSFileHandleConnectionAcceptedNotification for a server process (From: Matt Mashyna <email@hidden>)
 >Re: Using NSFileHandleConnectionAcceptedNotification for a server process (From: Jens Alfke <email@hidden>)
 >Re: Using NSFileHandleConnectionAcceptedNotification for a server process (From: Matt Mashyna <email@hidden>)

  • Prev by Date: Re: wired things about NSApp Modal
  • Next by Date: Re: references to controllers in document based applications
  • Previous by thread: Re: Using NSFileHandleConnectionAcceptedNotification for a server process
  • Next by thread: Leopard and Tiger Notification Differences?
  • Index(es):
    • Date
    • Thread