Package naga
Interface ConnectionAcceptor
public interface ConnectionAcceptor
The ConnectionAcceptor is used by the NIOServerSocket to determine
if a connection should be accepted or refused.
This can be used to implement black-listing of certain IP-ranges or to limit the number of simultaneous connection. However, in most cases it is enough to use the ConnectorAcceptor.ALLOW which accepts all incoming connections.
Note that a NIOServerSocket defaults to the ConnectorAcceptor.ALLOW acceptor when it is created.
- Author:
- Christoffer Lerno
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ConnectionAcceptor
A connection acceptor that accepts all connections.static final ConnectionAcceptor
A connection acceptor that refuses all connections. -
Method Summary
Modifier and TypeMethodDescriptionboolean
acceptConnection
(InetSocketAddress inetSocketAddress) Return true if the connection should be accepted, false otherwise.
-
Field Details
-
DENY
A connection acceptor that refuses all connections. -
ALLOW
A connection acceptor that accepts all connections.
-
-
Method Details
-
acceptConnection
Return true if the connection should be accepted, false otherwise.Note: This callback is run on the NIOService thread. This means it will block all other reads, writes and accepts on the service while it executes. For this reason it is recommended that this method should return fairly quickly (i.e. don't make reverse ip lookups or similar - potentially very slow - calls).
- Parameters:
inetSocketAddress
- the adress the connection came from.- Returns:
- true to accept, false to refuse.
-