SocketControl

Trait SocketControl 

Source
pub trait SocketControl {
    // Required methods
    fn bind(&self, address: &SocketAddress) -> Result<(), SocketError>;
    fn connect(&self, address: &SocketAddress) -> Result<(), SocketError>;
    fn listen(&self, backlog: usize) -> Result<(), SocketError>;
    fn accept(&self) -> Result<Arc<dyn SocketObject>, SocketError>;
    fn getpeername(&self) -> Result<SocketAddress, SocketError>;
    fn getsockname(&self) -> Result<SocketAddress, SocketError>;
    fn shutdown(&self, how: ShutdownHow) -> Result<(), SocketError>;
    fn is_connected(&self) -> bool;
    fn state(&self) -> SocketState;
}
Expand description

Socket control operations trait

Provides OS-agnostic socket control, similar to TtyControl for TTY devices. ABI modules translate their specific socket operations to these neutral controls.

Required Methods§

Source

fn bind(&self, address: &SocketAddress) -> Result<(), SocketError>

Bind socket to an address

Source

fn connect(&self, address: &SocketAddress) -> Result<(), SocketError>

Connect to a remote address

Source

fn listen(&self, backlog: usize) -> Result<(), SocketError>

Listen for incoming connections (for stream sockets)

Source

fn accept(&self) -> Result<Arc<dyn SocketObject>, SocketError>

Accept an incoming connection (for listening sockets) Returns a new socket for the accepted connection

Source

fn getpeername(&self) -> Result<SocketAddress, SocketError>

Get socket peer address

Source

fn getsockname(&self) -> Result<SocketAddress, SocketError>

Get socket local address

Source

fn shutdown(&self, how: ShutdownHow) -> Result<(), SocketError>

Shutdown socket for reading, writing, or both

Source

fn is_connected(&self) -> bool

Check if socket is connected

Source

fn state(&self) -> SocketState

Get socket state

Implementors§