net.i2p.router.transport.ntcp

## Interface EstablishState

- All Known Implementing Classes:
    EstablishBase, InboundEstablishState, OutboundNTCP2State

      interface EstablishState

  Interface for handling NTCP connection establishment state machine. Manages the handshake process for both NTCP 1 and NTCP 2 protocols, including parsing handshake data, preparing outbound connections, and tracking establishment completion status.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close(String reason, Exception e)` Release resources on timeout.
    `int` | `getVersion()` Get the NTCP version
    `boolean` | `isComplete()` If synchronized on this, fails with deadlocks from all over via CSFI.isEstablished().
    `boolean` | `isCorrupt()` did the handshake fail for some reason?
    `void` | `prepareOutbound()` Does nothing.
    `void` | `receive(ByteBuffer src)` Parse the contents of the buffer as part of the handshake.

- - ### Method Detail

    - #### close

          void close(String reason,
                     Exception e)

      Release resources on timeout.
      Parameters:
        `e` - may be null

    - #### getVersion

          int getVersion()

      Get the NTCP version
      Returns:
        1, 2, or 0 if unknown

    - #### isComplete

          boolean isComplete()

      If synchronized on this, fails with deadlocks from all over via CSFI.isEstablished(). Also CSFI.getFramedAveragePeerClockSkew().
      Returns:
        is the handshake complete and valid?

    - #### isCorrupt

          boolean isCorrupt()

      did the handshake fail for some reason?

    - #### prepareOutbound

          void prepareOutbound()

      Does nothing. Outbound (Alice) must override. We are establishing an outbound connection, so prepare ourselves by queueing up the write of the first part of the handshake
      Throws:
        `IllegalStateException`

    - #### receive

          void receive(ByteBuffer src)

      Parse the contents of the buffer as part of the handshake. All data must be copied out of the buffer as Reader.processRead() will return it to the pool. If there are additional data in the buffer after the handshake is complete, the EstablishState is responsible for passing it to NTCPConnection.
      Throws:
        `IllegalStateException`