public interface ConnectionAcceptor
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.
Modifier and Type | Field | Description |
---|---|---|
static ConnectionAcceptor |
ALLOW |
A connection acceptor that accepts all connections.
|
static ConnectionAcceptor |
DENY |
A connection acceptor that refuses all connections.
|
Modifier and Type | Method | Description |
---|---|---|
boolean |
acceptConnection(java.net.InetSocketAddress inetSocketAddress) |
Return true if the connection should be accepted, false otherwise.
|
static final ConnectionAcceptor DENY
static final ConnectionAcceptor ALLOW
boolean acceptConnection(java.net.InetSocketAddress inetSocketAddress)
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).
inetSocketAddress
- the adress the connection came from.