pub struct TcpSocket { /* private fields */ }Expand description
Low level synchronous TCP socket.
Implementations§
Source§impl TcpSocket
impl TcpSocket
Sourcepub fn from_config(config: &TcpConfig) -> Result<Self>
pub fn from_config(config: &TcpConfig) -> Result<Self>
Build a socket according to TcpSocketConfig.
Sourcepub fn new(domain: Domain, sock_type: SockType) -> Result<Self>
pub fn new(domain: Domain, sock_type: SockType) -> Result<Self>
Create a socket of arbitrary type (STREAM or RAW).
pub fn bind(&self, addr: SocketAddr) -> Result<()>
pub fn connect(&self, addr: SocketAddr) -> Result<()>
pub fn connect_timeout( &self, target: SocketAddr, timeout: Duration, ) -> Result<TcpStream>
pub fn listen(&self, backlog: i32) -> Result<()>
pub fn accept(&self) -> Result<(TcpStream, SocketAddr)>
pub fn to_tcp_stream(self) -> Result<TcpStream>
pub fn to_tcp_listener(self) -> Result<TcpListener>
Sourcepub fn send_to(&self, buf: &[u8], target: SocketAddr) -> Result<usize>
pub fn send_to(&self, buf: &[u8], target: SocketAddr) -> Result<usize>
Send a raw packet (for RAW TCP use).
Sourcepub fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>
pub fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>
Receive a raw packet (for RAW TCP use).
pub fn set_reuseaddr(&self, on: bool) -> Result<()>
pub fn set_nodelay(&self, on: bool) -> Result<()>
pub fn set_linger(&self, dur: Option<Duration>) -> Result<()>
pub fn set_ttl(&self, ttl: u32) -> Result<()>
pub fn set_bind_device(&self, iface: &str) -> Result<()>
pub fn local_addr(&self) -> Result<SocketAddr>
pub fn as_raw_fd(&self) -> RawFd
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TcpSocket
impl RefUnwindSafe for TcpSocket
impl Send for TcpSocket
impl Sync for TcpSocket
impl Unpin for TcpSocket
impl UnwindSafe for TcpSocket
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more