enum SocketState {
Initial(Socket),
Listening(TcpListener),
Connecting(TcpStream),
Connected(TcpStream),
ConnectionFailed(TcpStream),
None,
}Variants§
Initial(Socket)
No syscall after socket has been made.
Listening(TcpListener)
The listen syscall has been called on the socket.
This is reachable from the SocketState::Initial and the
SocketState::Listening states.
Connecting(TcpStream)
The connect syscall has been called and we weren’t yet able
to ensure the connection is established. This is only reachable
from the SocketState::Initial state.
Connected(TcpStream)
The connect syscall has been called on the socket and
we ensured that the connection is established, or
the socket was created by the accept syscall.
For a socket created using the connect syscall, this is
only reachable from the SocketState::Connecting state.
ConnectionFailed(TcpStream)
The SO_ERROR socket option has been set after calling
the connect syscall, indicating that the connection
attempt failed. By the POSIX specification, a socket is
is an unspecified state after a failed connection attempt
and thus nothing (except destroying the socket) should be
supported when a socket is in this state.
None
The socket state machine is transitioning between two states which contain an underlying host socket. This state is never observable, it’s only needed as a placeholder state to safely acquire ownership of the underlying host socket.
Implementations§
Source§impl SocketState
impl SocketState
Sourcefn as_socket_ref<'a>(&'a self) -> SockRef<'a>
fn as_socket_ref<'a>(&'a self) -> SockRef<'a>
View the underlying host socket as a [socket2::SockRef].
Note: Potentially blocking operations need to be performed on the
underlying [TcpStream] and [TcpListener] as it would break the mio
poll on Windows hosts when performed directly on the [socket2::SockRef].
Trait Implementations§
Auto Trait Implementations§
impl DynSend for SocketState
impl DynSync for SocketState
impl Freeze for SocketState
impl RefUnwindSafe for SocketState
impl Send for SocketState
impl Sync for SocketState
impl Unpin for SocketState
impl UnsafeUnpin for SocketState
impl UnwindSafe for SocketState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 8 bytes
Size for each variant:
Initial: 4 bytesListening: 4 bytesConnecting: 4 bytesConnected: 4 bytesConnectionFailed: 4 bytesNone: 0 bytes