SocketObject

Trait SocketObject 

Source
pub trait SocketObject:
    StreamIpcOps
    + SocketControl
    + Send
    + Sync {
    // Required methods
    fn socket_type(&self) -> SocketType;
    fn socket_domain(&self) -> SocketDomain;
    fn socket_protocol(&self) -> SocketProtocol;
    fn as_any(&self) -> &dyn Any
       where Self: 'static;

    // Provided methods
    fn sendto(
        &self,
        data: &[u8],
        address: &SocketAddress,
        flags: u32,
    ) -> Result<usize, SocketError> { ... }
    fn recvfrom(
        &self,
        buffer: &mut [u8],
        flags: u32,
    ) -> Result<(usize, SocketAddress), SocketError> { ... }
    fn as_selectable(&self) -> Option<&dyn Selectable> { ... }
    fn as_control_ops(&self) -> Option<&dyn ControlOps> { ... }
}
Expand description

Socket operations trait

Combines StreamIpcOps (for data transfer), SocketControl (for connection management), and CloneOps (for handle duplication). This is the main trait that socket implementations must satisfy.

Similar to how TtyDeviceEndpoint combines CharDevice + TtyControl.

Required Methods§

Source

fn socket_type(&self) -> SocketType

Get socket type (Stream, Datagram, etc.)

Source

fn socket_domain(&self) -> SocketDomain

Get socket domain (Local, Inet, Inet6, etc.)

Source

fn socket_protocol(&self) -> SocketProtocol

Get socket protocol

Source

fn as_any(&self) -> &dyn Any
where Self: 'static,

Cast to Any for safe downcasting

Provided Methods§

Source

fn sendto( &self, data: &[u8], address: &SocketAddress, flags: u32, ) -> Result<usize, SocketError>

Send data to a specific address (for datagram sockets) For stream sockets, address is ignored and data is sent to connected peer

Source

fn recvfrom( &self, buffer: &mut [u8], flags: u32, ) -> Result<(usize, SocketAddress), SocketError>

Receive data with source address (for datagram sockets) For stream sockets, returns Unspecified address

Source

fn as_selectable(&self) -> Option<&dyn Selectable>

Optional capability: expose select/pselect readiness/wait interface

Source

fn as_control_ops(&self) -> Option<&dyn ControlOps>

Optional capability: expose control operations interface

Implementors§