Power Manager and the Network
Power Manager consists of a collection of processes. These processes include the Power Manager application, the Scheduler, and per-user assistants.
These processes need to find and talk to each other. This section discusses how this communication works.
On Start Up
The Scheduler is launched and kept running using a macOS
launchd job stored in
/Library/LaunchDaemons; see List Power Manager's launchd jobs.
The Scheduler opens and listens on a TCP/IP socket. The socket's port is assigned by macOS to avoid conflicting with other processes. Only connections originating on the same computer are accepted (local host only); see List Power Manager's TCP/IP sockets.
The Scheduler needs to let other processes know what port is being used. To do this, the Schedule registers a local only service using macOS's
dns-sd (Service Discovery); see List Power Manager's Service Discovery entries and Supporting Bonjour for the registered service details.
Talking to the Scheduler
When the Power Manager application or another process needs to talk to the Scheduler, the following steps are performed.
The process asks macOS's
dns-sd if a service matching the Scheduler has been registered.
If the Scheduler has not registered with
dns-sd, then the asking process assumes the Scheduler is not running on the computer.
If the Scheduler has registered,
dns-sd provides the asking process with the port needed to connect to the Scheduler.
With the socket's port provided by
dns-sd, the process can now open an encrypted local TCP/IP connection to the Scheduler.
You can explore and confirm each step of this process using the commands below.
List Power Manager's launchd jobs
sudo launchctl list | grep uk\.co\.dssw\.powermanager
List Power Manager's TCP/IP sockets
sudo lsof -i | grep uk\.co
List Power Manager's Service Discovery entries
dns-sd -B _pm._tcp.