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>;
}
Required Methods§
sourcefn connect(&mut self, timeout: Option<Duration>) -> CDnsResult<()>
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!
sourcefn is_conncected(&self) -> bool
fn is_conncected(&self) -> bool
Tells if socket/stream is connected to remote host
sourcefn get_fd(&self) -> Option<BorrowedFd<'_>>
fn get_fd(&self) -> Option<BorrowedFd<'_>>
Returns the raw fd of the socket.
sourcefn get_remote_addr(&self) -> &SocketAddr
fn get_remote_addr(&self) -> &SocketAddr
Returns the remote host Ip and port.
sourcefn send(&mut self, sndbuf: &[u8]) -> CDnsResult<usize>
fn send(&mut self, sndbuf: &[u8]) -> CDnsResult<usize>
Sends data over wire.
sourcefn recv(&mut self, rcvbuf: &mut [u8]) -> CDnsResult<usize>
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.