• 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: NSFileHandle socket question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSFileHandle socket question


  • Subject: Re: NSFileHandle socket question
  • From: email@hidden
  • Date: Mon, 24 Dec 2001 10:17:38 +0100

Doug,

By the way. It is also in the documentation. It says that readInBackGroundAndNotify uses availableData. And the description of availableData says:
"If the receiver is a communications channel, reads up to a buffer of data and returns it; if no data is available, the method blocks. Returns an empty NSData if the end of file is reached. Raises NSFileHandleOperationException if attempts to determine file-handle type fail or if attempts to read from the file or channel fail."
And the end of file for a socket is reached when the connection is closed.

What I like to know however is what happens when readInBackGroundAndNotify encounters an exception that was raised by availableData. Does it then close the connection and also send an empty NSData?

Rgrds,
Sander

On maandag, december 24, 2001, at 05:40 , Dustin Mierau wrote:

Doug,

I think this works the same way recv() does, if you a size of 0 is passed to your callback, the connection has closed. You might just want to use the socket api directly and skip the NSFileHandle stuff, it will give you a little more flexibility.

-dustin

On Sunday, December 23, 2001, at 05:31 PM, Doug Brown wrote:

Hi,

I have been working on creating a socket for an app that I'm working on, and NSFileHandle seems to be the perfect way to handle sending and receiving data - it's working just great with -readInBackgroundAndNotify. I am baffled at one thing, though. How do I find out if the remote side closed the connection? I don't see any method or notification that would tell me when the connection is closed. I need to know this so I can tell the user that the connection was dropped and reset everything so the app knows it is disconnected from the server again. Thanks,

Doug
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: NSFileHandle socket question (From: Dustin Mierau <email@hidden>)

  • Prev by Date: Re: NSFileHandle socket question
  • Next by Date: Re: Drag and Drop to Finder (again)
  • Previous by thread: Re: NSFileHandle socket question
  • Next by thread: Re: NSFileHandle socket question
  • Index(es):
    • Date
    • Thread