net.i2p.router.client

## Class ClientListenerRunner

- java.lang.Object
- - net.i2p.router.client.ClientListenerRunner

- All Implemented Interfaces:
    Runnable
  Direct Known Subclasses:
    SSLClientListenerRunner

      class ClientListenerRunner
      extends Object
      implements Runnable

  Listen for connections on the specified port, and toss them onto the client manager's set of connections once they are established. This is not used for internal (in-JVM) connections - see ClientManager and QueuedClientConnectionRunner. Note that this is extended by SSLClientListenerRunner for SSL, and by DomainClientListenerRunner in Android for domain sockets.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `_bindAllInterfaces`
    `protected RouterContext` | `_context`
    `protected boolean` | `_listening`
    `protected Log` | `_log`
    `protected ClientManager` | `_manager`
    `protected int` | `_port`
    `protected boolean` | `_running`
    `protected ServerSocket` | `_socket`
    `static String` | `BIND_ALL_INTERFACES`
    `protected static int` | `CONNECT_TIMEOUT` give the i2cp client 5 seconds to show that they're really i2cp clients

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClientListenerRunner(RouterContext context, ClientManager manager, int port)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected ServerSocket` | `getServerSocket()` Get a ServerSocket.
    `boolean` | `isListening()`
    `void` | `run()`
    `protected void` | `runConnection(Socket socket)` Handle the connection by passing it off to a `ClientConnectionRunner`
    `protected void` | `runServer()` Start up the socket listener, listens for connections, and fires those connections off via `runConnection`.
    `void` | `stopListening()`
    `protected boolean` | `validate(Socket socket)` Verify the first byte.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### _bindAllInterfaces

          protected final boolean _bindAllInterfaces

    - #### _context

          protected final RouterContext _context

    - #### _listening

          protected volatile boolean _listening

    - #### _log

          protected final Log _log

    - #### _manager

          protected final ClientManager _manager

    - #### _port

          protected final int _port

    - #### _running

          protected volatile boolean _running

    - #### _socket

          protected ServerSocket _socket

    - #### BIND_ALL_INTERFACES

          public static final String BIND_ALL_INTERFACES

      See Also:
        Constant Field Values

    - #### CONNECT_TIMEOUT

          protected static final int CONNECT_TIMEOUT

      give the i2cp client 5 seconds to show that they're really i2cp clients
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ClientListenerRunner

          public ClientListenerRunner(RouterContext context,
                                      ClientManager manager,
                                      int port)

  - ### Method Detail

    - #### getServerSocket

          protected ServerSocket getServerSocket()
                                          throws IOException

      Get a ServerSocket. Split out so it can be overridden for SSL.
      Throws:
        `IOException`

    - #### isListening

          public boolean isListening()

    - #### run

          public void run()

      Specified by:
        `run` in interface `Runnable`

    - #### runConnection

          protected void runConnection(Socket socket)

      Handle the connection by passing it off to a `ClientConnectionRunner`

    - #### runServer

          protected void runServer()

      Start up the socket listener, listens for connections, and fires those connections off via `runConnection`. This only returns if the socket cannot be opened or there is a catastrophic failure.

    - #### stopListening

          public void stopListening()

    - #### validate

          protected boolean validate(Socket socket)

      Verify the first byte.