ConnectionAcceptor (Naga API)
Date: 2016-06-28

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

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static ConnectionAcceptor` | `ALLOW` A connection acceptor that accepts all connections.
    `static ConnectionAcceptor` | `DENY` A connection acceptor that refuses all connections.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `acceptConnection(java.net.InetSocketAddress inetSocketAddress)` Return true if the connection should be accepted, false otherwise.

- - ### Field Detail

    - #### DENY

          static final ConnectionAcceptor DENY

      A connection acceptor that refuses all connections.

    - #### ALLOW

          static final ConnectionAcceptor ALLOW

      A connection acceptor that accepts all connections.

  - ### Method Detail

    - #### acceptConnection

          boolean acceptConnection(java.net.InetSocketAddress inetSocketAddress)

      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.