Trait SocketTap

Source
pub trait SocketTap {
    // Required methods
    fn connect(&mut self, timeout: Option<Duration>) -> CDnsResult<()>;
    fn is_tcp(&self) -> bool;
    fn is_conncected(&self) -> bool;
    fn get_fd(&self) -> Option<BorrowedFd<'_>>;
    fn get_remote_addr(&self) -> &SocketAddr;
    fn send(&mut self, sndbuf: &[u8]) -> CDnsResult<usize>;
    fn recv(&mut self, rcvbuf: &mut [u8]) -> CDnsResult<usize>;
}
Expand description

A common interface to access the realizations for both TcpStream and UdpSocket

Required Methods§

Source

fn connect(&mut self, timeout: Option<Duration>) -> CDnsResult<()>

Connects to the remote host.
If timeout is not set, the socket is initialized in non blocking mode and [PollFd] is created to use with poll(2).
If timeout is set, then the socket is initialized in blocking mode with timeout. Tht [PollFd] is not generated!

Source

fn is_tcp(&self) -> bool

Tells if current instance is TcpStream if true, or UdpSocket if false

Source

fn is_conncected(&self) -> bool

Tells if socket/stream is connected to remote host

Source

fn get_fd(&self) -> Option<BorrowedFd<'_>>

Returns the raw fd of the socket.

Source

fn get_remote_addr(&self) -> &SocketAddr

Returns the remote host Ip and port.

Source

fn send(&mut self, sndbuf: &[u8]) -> CDnsResult<usize>

Sends data over wire.

Source

fn recv(&mut self, rcvbuf: &mut [u8]) -> CDnsResult<usize>

Receives data transmitted from remote host. In nonblocking mode it should be called only after the event was polled In blocking mode it will block until received or timeout.

Trait Implementations§

Source§

impl Debug for dyn SocketTap

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Implementors§