Re: Sleep, NSWorkspaceWillSleepNotification, 30 seconds and the run loop
Re: Sleep, NSWorkspaceWillSleepNotification, 30 seconds and the run loop
- Subject: Re: Sleep, NSWorkspaceWillSleepNotification, 30 seconds and the run loop
- From: "email@hidden" <email@hidden>
- Date: Fri, 2 Oct 2009 21:43:29 +0100
On 2 Oct 2009, at 20:50, Jens Alfke wrote:
On Oct 2, 2009, at 2:50 AM, email@hidden 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@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