When OS Sleep disabling network access

Hi,

I am finding that network access is lost from my application when the computer goes to sleep.

When I receive kIOMessageSystemWillSleep, I want to send a message to another computer. But I am finding it does not always make it to the other end. Sometimes it only get sent when the computer wakes back up.

Replies

I presume you’re on macOS here.

If so, you should expect to lose network connectivity when the system sleeps. On sleep the CPU stops, meaning there’s nothing available to run the networking stack [1].

When I receive kIOMessageSystemWillSleep, I want to send a message to another computer.

What networking API are you using to send that message?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] I’m glossing over a bunch of subtleties here (-:

  • Hey Quinn,

    Thanks for your response. I am on macOS.

    I was wondering if there would be time between receiving kIOMessageSystemWillSleep, and before I call IOAllowPowerChange, where networking is still available. I am finding its not consistently available.

    The networking API we use I am not sure.

  • Hey Quinn, Can I use kIOPMAssertNetworkClientActive with a timeout to get my message through?

Add a Comment

Thank you for the response, I was looking for the same.

I was wondering if there would be time between receiving kIOMessageSystemWillSleep, and before I call IOAllowPowerChange, where networking is still available.

Yeah, that’s the direction I was heading.

The networking API we use I am not sure.

That’s kinda important. Different APIs give you different levels of control over timing-related issues like this.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"