Initialization, run, start and exit events

An application’s initialization handler and start handler are invoked when the server starts up. The exit handler is invoked when the server shuts down. Initialization and exit handlers are typically used to manage global resources used by the application. The sequence is as follows:

  1. Server initialization – Initialization handler (if installed) is called.

  2. Server start-up – Initialization handler has returned. The Start handler is called. The server is now ready to spawn new threads, but will not accept client connections until after the Start handler returns. The Start handler can spawn service (non-client) threads if necessary.

  3. Normal operation – The server accepts client connections and associates each with a thread, spawning new threads when necessary. Each time a client connects, the server calls the application’s connect handler. Each time a client disconnects, the server calls the application’s disconnect handler.

  4. Server shutdown – The server terminates all threads, then calls the exit handler.