pub struct TcpSocket { /* private fields */ }
Expand description
Implementations§
Source§impl TcpSocket
impl TcpSocket
Sourcepub fn local_addr(&self) -> AxResult<SocketAddr>
pub fn local_addr(&self) -> AxResult<SocketAddr>
Returns the local address and port, or
Err(NotConnected)
if not connected.
Sourcepub fn peer_addr(&self) -> AxResult<SocketAddr>
pub fn peer_addr(&self) -> AxResult<SocketAddr>
Returns the remote address and port, or
Err(NotConnected)
if not connected.
Sourcepub fn is_nonblocking(&self) -> bool
pub fn is_nonblocking(&self) -> bool
Returns whether this socket is in nonblocking mode.
Sourcepub fn set_nonblocking(&self, nonblocking: bool)
pub fn set_nonblocking(&self, nonblocking: bool)
Moves this TCP stream into or out of nonblocking mode.
This will result in read
, write
, recv
and send
operations
becoming nonblocking, i.e., immediately returning from their calls.
If the IO operation is successful, Ok
is returned and no further
action is required. If the IO operation could not be completed and needs
to be retried, an error with kind Err(WouldBlock)
is
returned.
Sourcepub fn connect(&self, remote_addr: SocketAddr) -> AxResult
pub fn connect(&self, remote_addr: SocketAddr) -> AxResult
Connects to the given address and port.
The local port is generated automatically.
Sourcepub fn bind(&self, local_addr: SocketAddr) -> AxResult
pub fn bind(&self, local_addr: SocketAddr) -> AxResult
Sourcepub fn recv(&self, buf: &mut [u8]) -> AxResult<usize>
pub fn recv(&self, buf: &mut [u8]) -> AxResult<usize>
Receives data from the socket, stores it in the given buffer.
Sourcepub fn nodelay(&self) -> AxResult<bool>
pub fn nodelay(&self) -> AxResult<bool>
Checks if Nagle’s algorithm is enabled for this TCP socket.
Sourcepub fn set_nodelay(&self, enabled: bool) -> AxResult<()>
pub fn set_nodelay(&self, enabled: bool) -> AxResult<()>
Enables or disables Nagle’s algorithm for this TCP socket.
Sourcepub fn recv_capacity(&self) -> AxResult<usize>
pub fn recv_capacity(&self) -> AxResult<usize>
Returns the maximum capacity of the receive buffer in bytes.
Sourcepub fn send_capacity(&self) -> AxResult<usize>
pub fn send_capacity(&self) -> AxResult<usize>
Returns the maximum capacity of the send buffer in bytes.