pub struct TcpStream { /* private fields */ }Expand description
A TCP stream.
Implementations§
Source§impl TcpStream
impl TcpStream
Sourcepub const fn local_addr(&self) -> SocketAddr
pub const fn local_addr(&self) -> SocketAddr
Report the local endpoint to which this stream is connected.
Sourcepub const fn remote_addr(&self) -> SocketAddr
pub const fn remote_addr(&self) -> SocketAddr
Report the remote endpoint to which this stream is connected.
Sourcepub fn send_blocking(&self, b: &[u8]) -> Result<usize, Error>
pub fn send_blocking(&self, b: &[u8]) -> Result<usize, Error>
Send bytes to the remote.
Blocks until at least one byte can be queued. The return value is the number of bytes actually sent.
Sourcepub async fn send(&self, b: &[u8]) -> Result<usize, Error>
pub async fn send(&self, b: &[u8]) -> Result<usize, Error>
Send bytes to the remote.
Blocks until at least one byte can be queued. The return value is the number of bytes actually sent.
Sourcepub fn recv_blocking(&self, b: &mut [u8]) -> Result<usize, Error>
pub fn recv_blocking(&self, b: &mut [u8]) -> Result<usize, Error>
Receive bytes from the remote.
Returns the number of bytes actually received (blocks until there is at least one).
Sourcepub async fn recv(&self, b: &mut [u8]) -> Result<usize, Error>
pub async fn recv(&self, b: &mut [u8]) -> Result<usize, Error>
Receive bytes from the remote into the supplied buffer.
Returns the number of bytes actually received (blocks until there is at least one).
Sourcepub fn recv_bytes_blocking(&self) -> Result<Bytes, Error>
pub fn recv_bytes_blocking(&self) -> Result<Bytes, Error>
Receive bytes from the remote.
Returns the number of bytes actually received (blocks until there is at least one).
Sourcepub async fn recv_bytes(&self) -> Result<Bytes, Error>
pub async fn recv_bytes(&self) -> Result<Bytes, Error>
Receive bytes from the remote.