Class TcpServer

All Implemented Interfaces:
Iterable<ComponentType>, Channel, ComponentType, Eligible, Manager, NioHandler

public class TcpServer extends TcpConnectionManager implements NioHandler
Provides a TCP server.

The server binds to the given address. If the address is null, address and port are automatically assigned. The port may be overwritten by a configuration event (see onConfigurationUpdate(ConfigurationUpdate)).

For each established connection, the server creates a new LinkedIOSubchannel. The servers basic operation is to fire Input (and Closed) events on the appropriate subchannel in response to data received from the network and to handle Output (and Close) events on the subchannel and forward the information to the network connection.

The server supports limiting the number of concurrent connections with a PermitsPool. If such a pool is set as connection limiter (see setConnectionLimiter(PermitsPool)), a permit is acquired for each new connection attempt. If no more permits are available, the server sends a Purge event on each channel that is purgeable for at least the time span set with setMinimalPurgeableTime(long). Purgeability is derived from the end of record flag of Output events (see TcpConnectionManager.onOutput(Output, TcpChannelImpl). When using this feature, make sure that connections are either short lived or the application level components support the Purge event. Else, it may become impossible to establish new connections.