Enum Class ConnectionState
- All Implemented Interfaces:
Serializable, Comparable<ConnectionState>, Constable
Represents the lifecycle state of a transport connection.
This enum tracks the connection state machine for both client and server sockets in the io_uring transport backend. State transitions are thread-safe via volatile field access in the backend.
State Machine
┌──────────────┐
│ DISCONNECTED │ (Initial state)
└──────┬───────┘
│ connect() called
▼
┌──────────────┐
│ CONNECTING │ (Async connect in progress)
└──────┬───────┘
┌───────────────┴───────────────┐
│ success │ failure
▼ ▼
┌──────────────┐ ┌──────────────┐
│ CONNECTED │ │ DISCONNECTED │
└──────┬───────┘ └──────────────┘
│ close() called or error
▼
┌──────────────┐
│ CLOSING │ (Graceful shutdown)
└──────┬───────┘
│ cleanup complete
▼
┌──────────────┐
│ CLOSED │ (Terminal state)
└──────────────┘
Thread Safety
State transitions should be performed under synchronization in the backend. State checks (canConnect, canDoIO, canClose) can be performed without synchronization for fast-path decisions.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionConnection closed - terminal state.Graceful shutdown in progress.Connection established and ready for I/O operations.Asynchronous connection attempt in progress.Initial state - no connection established. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanClose()Checks if the close operation can be initiated in this state.booleanChecks if the connect operation can be initiated in this state.booleancanDoIO()Checks if I/O operations (send/receive) can be performed in this state.static ConnectionStateReturns the enum constant of this class with the specified name.static ConnectionState[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
DISCONNECTED
Initial state - no connection established. Valid operations:connect(),bind() -
CONNECTING
Asynchronous connection attempt in progress. The io_uring connect operation has been submitted but not yet completed. No I/O operations are allowed in this state. -
CONNECTED
Connection established and ready for I/O operations. Valid operations:send(),receive(),close() -
CLOSING
Graceful shutdown in progress. Outstanding I/O operations are being drained before final close. No new I/O operations are allowed. -
CLOSED
Connection closed - terminal state. No operations are allowed. Backend resources have been released.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
canConnect
public boolean canConnect()Checks if the connect operation can be initiated in this state.- Returns:
- true if state is DISCONNECTED (ready for new connection)
-
canDoIO
public boolean canDoIO()Checks if I/O operations (send/receive) can be performed in this state.- Returns:
- true if state is CONNECTED (ready for I/O)
-
canClose
public boolean canClose()Checks if the close operation can be initiated in this state.- Returns:
- true if state is CONNECTED or CONNECTING (active connection to close)
-