## net.i2p.router.transport.tcp
Class ConnectionHandler

    java.lang.Object
      net.i2p.router.transport.tcp.ConnectionHandler

public class ConnectionHandler
extends java.lang.Object

Class responsible for all of the handshaking necessary to turn a socket into a TCPConnection.

Field Summary
`static byte` `FLAG_PROTOCOL_NONE` protocol version sent if no protocols are ok
`static byte` `FLAG_TAG_FOLLOWING` alice is sending a tag to bob
`static byte` `FLAG_TAG_NOT_FOLLOWING` alice is not sending a tag to bob
`static byte` `FLAG_TAG_NOT_OK` the connection tag is not ok (must go with a full DH)
`static byte` `FLAG_TAG_OK` the connection tag is ok (we have an available key for it)
`static int` `FLAG_TEST` for reading/comparing, this is the #bytes sent if we are being tested
`static int` `STATUS_OK` the peer is fine
`static int` `STATUS_SIGNATURE_FAILED` the peer's signature failed (either some crazy corruption or MITM)
`static int` `STATUS_SKEWED` the peer's clock is too far skewed
`static int` `STATUS_UNKNOWN` dunno why the peer is bad
`static int` `STATUS_UNREACHABLE` the peer's public addresses could not be verified

Constructor Summary
`ConnectionHandler(RouterContext ctx, TCPTransport transport, java.net.Socket socket)`

Method Summary
`java.lang.String` `getError()`
`boolean` `getTestComplete()`
`static void` `main(java.lang.String[] args)` Verify the reachability of a peer.
`TCPConnection` `receiveConnection()` Blocking call to establish a TCP connection over the current socket.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### FLAG_TEST

    public static final int FLAG_TEST

  for reading/comparing, this is the #bytes sent if we are being tested

  See Also:
    Constant Field Values

### FLAG_PROTOCOL_NONE

    public static final byte FLAG_PROTOCOL_NONE

  protocol version sent if no protocols are ok

  See Also:
    Constant Field Values

### FLAG_TAG_FOLLOWING

    public static final byte FLAG_TAG_FOLLOWING

  alice is sending a tag to bob

  See Also:
    Constant Field Values

### FLAG_TAG_NOT_FOLLOWING

    public static final byte FLAG_TAG_NOT_FOLLOWING

  alice is not sending a tag to bob

  See Also:
    Constant Field Values

### FLAG_TAG_OK

    public static final byte FLAG_TAG_OK

  the connection tag is ok (we have an available key for it)

  See Also:
    Constant Field Values

### FLAG_TAG_NOT_OK

    public static final byte FLAG_TAG_NOT_OK

  the connection tag is not ok (must go with a full DH)

  See Also:
    Constant Field Values

### STATUS_UNKNOWN

    public static final int STATUS_UNKNOWN

  dunno why the peer is bad

  See Also:
    Constant Field Values

### STATUS_UNREACHABLE

    public static final int STATUS_UNREACHABLE

  the peer's public addresses could not be verified

  See Also:
    Constant Field Values

### STATUS_SKEWED

    public static final int STATUS_SKEWED

  the peer's clock is too far skewed

  See Also:
    Constant Field Values

### STATUS_SIGNATURE_FAILED

    public static final int STATUS_SIGNATURE_FAILED

  the peer's signature failed (either some crazy corruption or MITM)

  See Also:
    Constant Field Values

### STATUS_OK

    public static final int STATUS_OK

  the peer is fine

  See Also:
    Constant Field Values

Constructor Detail

### ConnectionHandler

    public ConnectionHandler(RouterContext ctx,
                             TCPTransport transport,
                             java.net.Socket socket)

Method Detail

### receiveConnection

    public TCPConnection receiveConnection()

  Blocking call to establish a TCP connection over the current socket. At this point, no data whatsoever need to have been transmitted over the socket - the builder is responsible for all aspects of the handshaking.

  Returns:
    fully established but not yet running connection, or null on error

### getError

    public java.lang.String getError()

### getTestComplete

    public boolean getTestComplete()

### main

    public static void main(java.lang.String[] args)

  Verify the reachability of a peer. Usage: `ConnectionHandler hostname portNum`