- All Known Implementing Classes:
EstablishBase, EstablishBase.FailedEstablishState, EstablishBase.VerifiedEstablishState, 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 MethodsModifier and TypeMethodDescriptionvoidRelease resources on timeout.Failure reason, or null if not failed.intNTCP version.booleanIf synchronized on this, fails with deadlocks from all over viaCSFI.isEstablished().booleanWhether the handshake failed.voidDoes nothing.voidreceive(ByteBuffer src) Parse the contents of the buffer as part of the handshake.
Method Details
receive
Parse the contents of the buffer as part of the handshake.All data must be copied out of the buffer as
Reader.processRead(NTCPConnection)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.
- Parameters:
src- the buffer to parse- Throws:
IllegalStateException- on invalid state
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- on invalid state
isCorrupt
boolean isCorrupt()Whether the handshake failed.- Returns:
- whether the handshake failed
getFailReason
String getFailReason()Failure reason, or null if not failed.- Returns:
- the failure reason, or null if not failed
isComplete
boolean isComplete()If synchronized on this, fails with deadlocks from all over viaCSFI.isEstablished(). AlsoCSFI.getFramedAveragePeerClockSkew().- Returns:
- is the handshake complete and valid?
getVersion
int getVersion()NTCP version.- Returns:
- 1, 2, or 0 if unknown
close
Release resources on timeout.- Parameters:
reason- the text logged with the warning and returned bygetFailReason()e- may be null