ADC Home > Reference Library > Technical Q&As > Legacy Documents > Networking >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

Connecting to a Sleeping or Dozing Macintosh


Q: We are writing an application that requires us to connect to a remote machine via TCP/IP and talk to a background application running on that machine. However, we cannot connect to that machine when it is in sleep mode. Is there a way to keep the network services alive when a machine is in sleep mode? I've seen how you can keep the serial port alive, but not the network services.

A: When a Macintosh (usually a PowerBook) goes into the "sleep" state, it is incapable of responding to network requests - the connections actually shut down. There are some Macintosh computers, however, that will attempt to go into an energy-efficient mode know as "doze."

The sleep state is easy to prevent and is pretty well documented in the Power Manager chapter of Inside Mac: Devices under "The Sleep Queue" and "Sleep Procedures", and there is more information in TN 1046: Inside Macintosh: Devices - Power Manager Addenda.

If you wanted to prevent the system from sleeping or dozing, you would:

  1. Allocate a SleepQRec (preferably in the system heap).
  2. Set it up to call into your sleepHandler.
  3. When the computer attempts to sleep or doze, it will call your sleepHandler with a sleepRequest or dozeRequest selector.
  4. To prevent sleep from occurring, you simply return a nonzero value.

In the doze state, Open Transport networking is still enabled and TCP connections that are set up should still function. But it might take several packets received within a short period (try 10 per second) to wake the machine from its doze state. You might also consider pinging the machine first to get it out of doze.

Either way, you should be aware that it will take some time for the networking to reactivate, especially if virtual memory is enabled and the disk drive must spin up.

There is more information on controlling the Energy Manager in TN 1086: Power Management & The Energy Saver API.

[Jan 31 1997]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.