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§
Sourcefn socket_type(&self) -> SocketType
fn socket_type(&self) -> SocketType
Get socket type (Stream, Datagram, etc.)
Sourcefn socket_domain(&self) -> SocketDomain
fn socket_domain(&self) -> SocketDomain
Get socket domain (Local, Inet, Inet6, etc.)
Sourcefn socket_protocol(&self) -> SocketProtocol
fn socket_protocol(&self) -> SocketProtocol
Get socket protocol
Provided Methods§
Sourcefn sendto(
&self,
data: &[u8],
address: &SocketAddress,
flags: u32,
) -> Result<usize, SocketError>
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
Sourcefn recvfrom(
&self,
buffer: &mut [u8],
flags: u32,
) -> Result<(usize, SocketAddress), SocketError>
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
Sourcefn as_selectable(&self) -> Option<&dyn Selectable>
fn as_selectable(&self) -> Option<&dyn Selectable>
Optional capability: expose select/pselect readiness/wait interface
Sourcefn as_control_ops(&self) -> Option<&dyn ControlOps>
fn as_control_ops(&self) -> Option<&dyn ControlOps>
Optional capability: expose control operations interface