net.i2p.client.streaming.impl

## Class ConnectionHandler

- java.lang.Object
- - net.i2p.client.streaming.impl.ConnectionHandler

-     class ConnectionHandler
      extends Object

  Receive new connection attempts Use a bounded queue to limit the damage from SYN floods, router overload, or a slow client

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConnectionHandler(I2PAppContext context, ConnectionManager mgr, SimpleTimer2 timer)` Creates a new instance of ConnectionHandler

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Connection` | `accept(long timeoutMs)` Receive an incoming connection (built from a received SYN) Non-SYN packets with a zero SendStreamID may also be queued here so that they don't get thrown away while the SYN packet before it is queued.
    `boolean` | `getActive()`
    `void` | `receiveNewSyn(Packet packet)` Non-SYN packets with a zero SendStreamID may also be queued here so that they don't get thrown away while the SYN packet before it is queued.
    `void` | `setActive(boolean active)`
    `void` | `setRestartPending()` The router told us it's going to restart.

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

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

- - ### Constructor Detail

    - #### ConnectionHandler

          public ConnectionHandler(I2PAppContext context,
                                   ConnectionManager mgr,
                                   SimpleTimer2 timer)

      Creates a new instance of ConnectionHandler

  - ### Method Detail

    - #### accept

          public Connection accept(long timeoutMs)
                            throws RouterRestartException,
                                   ConnectException,
                                   SocketTimeoutException

      Receive an incoming connection (built from a received SYN) Non-SYN packets with a zero SendStreamID may also be queued here so that they don't get thrown away while the SYN packet before it is queued.
      Parameters:
        `timeoutMs` - max amount of time to wait for a connection (if less than 1ms, wait indefinitely)
      Returns:
        connection received. Prior to 0.9.17, or null if there was a timeout or the handler was shut down. As of 0.9.17, never null.
      Throws:
        `RouterRestartException` - (extends I2PException) if the router is apparently restarting, since 0.9.34
        `ConnectException` - since 0.9.17, returned null before; if the I2PServerSocket is closed, or if interrupted.
        `SocketTimeoutException` - since 0.9.17, returned null before; if a timeout was previously set with setSoTimeout and the timeout has been reached.

    - #### getActive

          public boolean getActive()

    - #### receiveNewSyn

          public void receiveNewSyn(Packet packet)

      Non-SYN packets with a zero SendStreamID may also be queued here so that they don't get thrown away while the SYN packet before it is queued. Additional overload protection may be required here... We don't have a 3-way handshake, so the SYN fully opens a connection. Does that make us more or less vulnerable to SYN flooding?

    - #### setActive

          public void setActive(boolean active)

    - #### setRestartPending

          public void setRestartPending()

      The router told us it's going to restart. Call instead of setActive(false).