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§
Sourcefn bind(&self, address: &SocketAddress) -> Result<(), SocketError>
fn bind(&self, address: &SocketAddress) -> Result<(), SocketError>
Bind socket to an address
Sourcefn connect(&self, address: &SocketAddress) -> Result<(), SocketError>
fn connect(&self, address: &SocketAddress) -> Result<(), SocketError>
Connect to a remote address
Sourcefn listen(&self, backlog: usize) -> Result<(), SocketError>
fn listen(&self, backlog: usize) -> Result<(), SocketError>
Listen for incoming connections (for stream sockets)
Sourcefn accept(&self) -> Result<Arc<dyn SocketObject>, SocketError>
fn accept(&self) -> Result<Arc<dyn SocketObject>, SocketError>
Accept an incoming connection (for listening sockets) Returns a new socket for the accepted connection
Sourcefn getpeername(&self) -> Result<SocketAddress, SocketError>
fn getpeername(&self) -> Result<SocketAddress, SocketError>
Get socket peer address
Sourcefn getsockname(&self) -> Result<SocketAddress, SocketError>
fn getsockname(&self) -> Result<SocketAddress, SocketError>
Get socket local address
Sourcefn shutdown(&self, how: ShutdownHow) -> Result<(), SocketError>
fn shutdown(&self, how: ShutdownHow) -> Result<(), SocketError>
Shutdown socket for reading, writing, or both
Sourcefn is_connected(&self) -> bool
fn is_connected(&self) -> bool
Check if socket is connected
Sourcefn state(&self) -> SocketState
fn state(&self) -> SocketState
Get socket state