Class TcpServer

A TcpServer can be bound to multiple addresses;
each address has a corresponding channel handler.
See TcpServer.Conf.handlers.

Life Cycle

The server can be in 4 states: init, accepting, acceptingPaused, acceptingStopped.

After start(), the server is in accepting state.
New incoming connections are accepted.

If pauseAccepting() is called, the server is in acceptingPaused state.
New connections are not accepted.
This is useful to protect the server when some resources are about to be exhausted.
The server socket ports are still owned by this server.
The server can be resumed to accepting state by resumeAccepting().

After stopAccepting(), the server is in acceptingStopped state.
New connections are not accepted.
The server socket ports are freed and can be grabbed by another server.
Existing connections are still functional until app closes them.
Check the number of live connections by getConnectionCount().

The stopAll() call will stop accepting new connections and kill all existing connections.
The server is then back to the init state.