public interface NIOServerSocket extends NIOAbstractSocket
The NIOServerSocket executes callbacks to a ServerSocket observer to react to new connections and other events.
Modifier and Type | Method and Description |
---|---|
long |
getTotalAcceptedConnections()
Returns the total number of accepted connections on this socket since
it opened.
|
long |
getTotalConnections()
Returns the total number of connections made on this socket since
it opened.
|
long |
getTotalFailedConnections()
Returns the total number of failed connections on this socket since
it opened.
|
long |
getTotalRefusedConnections()
Returns the total number of refused connections on this socket since
it opened.
|
void |
listen(ServerSocketObserver observer)
Associates a server socket observer with this server socket and
starts accepting connections.
|
void |
setConnectionAcceptor(ConnectionAcceptor acceptor)
Sets the connection acceptor for this server socket.
|
java.net.ServerSocket |
socket()
Allows access to the underlying server socket.
|
close, getAddress, getIp, getPort, getTag, isOpen, setTag
long getTotalConnections()
This method is thread-safe.
long getTotalRefusedConnections()
This method is thread-safe.
long getTotalAcceptedConnections()
This method is thread-safe.
long getTotalFailedConnections()
This method is thread-safe.
void listen(ServerSocketObserver observer)
This method is thread-safe, but may only be called once.
observer
- the observer to receive callbacks from this socket.java.lang.NullPointerException
- if the observer given is null.java.lang.IllegalStateException
- if an observer has already been set.void setConnectionAcceptor(ConnectionAcceptor acceptor)
A connection acceptor determines if a connection should be disconnected or not after the initial accept is done.
For more information, see the documentation for naga.ConnectionAcceptor
.
This method is thread-safe.
acceptor
- the acceptor to use, or null to default to
ConnectorAcceptor.DENY.java.net.ServerSocket socket()
Note calling close and similar functions on this socket will put the NIOServerSocket in an undefined state