The SDAP client and server implement the secure distributed administration protocol (SDAP) in Sendmail Switch. The SDAP server is a non-blocking asynchronous I/O network server (non-forking, non-threaded) implemented in Perl with pretty reasonable performance considering its implementation language.
SDAP::API
Commands are issued from the Administration Console by calling functions in the SDAP::API Perl module. Each API call in SDAP::API has an associated script along with it. The API call creates a SDAP::Connector, connects to the SDAP server and executes the script. The result from the operation is returned from the function.
SDAP::Connector
Establishes connection to remote host, and initializes a SDAP::ScriptClient to run the script requested.
ClientState.pm
This module contains all states used by the client to issue commands to the server and handle responses from the server.
SDAP::Listener
Listens on the server socket for incoming client connections. Launches a SDAP::Launcher on the socket.
ServerState.pm
This module contains all states used by the server to handle command requests from the client, execute those commands, and return a response to the client.
SDAP::State::Command
This class parses commands from the client, and dispatches other server states (e.g., SDAP::HELO, SDAP::NOOP, SDAP::QUIT) accordingly.
SDAP::Engine
The main select() loop. We select on read and write handlers registered with this engine and dispatch their callbacks when either read or write network activity occurs.
All read handlers are triggered as callbacks from a SDAP::Engine. They implement the SDAP::ReadHandler interface.
SDAP::Launcher
Performs the accept and initializes a new SDAP::Client, sends a greeting.
SDAP::Client
State machine which waits until a read request has been filled, then dispatches the state corresponding to the request. Read requests can either request a line or a fixed block of data. The following diagram illustrates the program flow of this read handler.

SDAP::ScriptClient
Extends the SDAP::Client package to include support for scripts or sequences of states to be executed.
All write handlers are triggered as callbacks from a SDAP::Engine. They implement the SDAP::WriteHandler interface.
SDAP::Writer
Send data from buffer to client. Any left over data is saved in the buffer and a new write notify is issued to the engine.
SDAP::FileWriter
Writes the contents of a file, a block at a time using a SDAP::Writer to write the block properly. A subroutine can be called at the end of a write.
SDAP::State
Each state contains a request parameter and pointers to its registered SDAP::Client (or SDAP::ScriptClient). Believe it or not, both the client and the server use the same engine, "client" object, and state machine. States for each are defined in their respective files.