Documentation Archive Developer
Search

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:

Putting Client/Server Systems to Sleep


Q: I am writing a fax client/server system and I have encountered a problem after I put the server to sleep: on waking, the server software does not seem to re-register on the network (using RegisterMyName).

On the client side, (when receiving a sleepDemand request), I wait until network activity has ceased, then return control to the system. The client wakes and reconnects to the server with no problems.

What action should I take to correct this problem?

A: In general, you might want to disable sleep on your server by informing the Power Manager with AutoSleepControl(false). Otherwise, the clients might never know that your server is sleeping, and will be unable to connect. But if you do want to support sleep, then a server should install a sleep procedure through the Power Manager using SleepQInstall.

The exact interaction of how your server should handle sleepRequest/SleepDemand is detailed in table 6-1 on pg 6-10 of Inside Macintosh: Devices. Ultimately, you close and deregister your server from the network. Later, when you get the sleepWakeUp call, you should reopen and re-register.

Q: I installed a sleep procedure. But the Power Manager will issue a sleepDemand if the user selects Sleep from the Special menu. The AutoSleepControl(false) call will stop sleepRequests but will it also stop SleepDemands?

A: Your Application can (should) not refuse a sleepDemand, as documented in Inside Macintosh: Devices pg 6-11:

When your sleep procedure receives a sleep demand, however, your procedure has no way to determine whether it originated as a conditional sleep demand or an unconditional sleep demand. Your device driver or application must prepare for the sleep state and return control promptly to the Power Manager when it receives a sleep demand.

As for AutoSleepControl, please refer to Inside Macintosh: Devices pg 6-44:

When enableSleep is set to false, the computer will not go into the sleep mode unless it is forced to either by some user action --for example, by the user's selecting Sleep from the Special menu of the Finder--or in a low battery situation.

[Jan 09 1997]