On 2 Oct 2009, at 20:50, Jens Alfke wrote:


On Oct 2, 2009, at 2:50 AM, [email protected] wrote:

Seems that by the time I get the IOKit sleep notification my Bonjour service has already disconnected so my packets end up going nowhere anyway.

How exactly is your Bonjour service implemented? Bonjour itself only does service discovery, not communication, so you must be using some other API to open and manage the sockets. I don't believe any of the system APIs take care of closing sockets on sleep, but maybe you're using a 3rd party library that does.

I am following the advice of the Bonjour docs and browsing as normal through the sleep. As far as I can tell sockets naturally persist through sleep though in my case I think it best to insist upon disconnection before sleep.

My problem was not so much that my sockets were closed as that my NSNetService instance stopped. As sleep looms I wanted to open a new socket and fire off some data - hence the need for NSNetService to be still active. I know that I could used a cached copy of the service IP rather than resolve it, however after rereading Richards I think the solution is:

1. Forget about what Bonjour does doing sleep.
2. Forget about trying to send more data before sleep.
3. When the client nears sleep close all open client sockets. The client observes the disconnection, updates the GUI and the sleeps. 4. When the server nears sleep close all open sockets, terminate all server activity for requests received on those sockets and then sleep.

—Jens

Jonathan Mitchell

Developer
http://www.mugginsoft.com





_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to