oa::TcpStream

One connected blocking TCP byte stream. This type owns its socket. Dropping it releases the socket; close makes that lifecycle transition explicit and idempotent. A clone obtained with try_clone shares the underlying TCP connection, including shutdown state.

StRust public API

Declaration

pub struct TcpStream { /* private fields */ }
Public Rust declaration.

Public Methods

pub fn read(&mut self, bytes: &mut [u8]) -> Result<usize>
pub fn write(&mut self, bytes: &[u8]) -> Result<usize>
pub fn write_all(&mut self, bytes: &[u8]) -> Result<()>
pub fn set_io_timeout(&self, timeout: Duration) -> Result<()>
pub fn try_clone(&self) -> Result<Self>
pub fn shutdown(&self) -> Result<()>
pub fn close(&mut self)
pub const fn is_open(&self) -> bool
pub const fn peer_addr(&self) -> SocketAddr
pub const fn remote_addr(&self) -> IpAddr
pub const fn remote_port(&self) -> u16

Associated Functions

pub fn connect(host: &str, port: u16) -> Result<Self>

Public Method Documentation

pub fn read( &mut self, bytes: &mut [u8] ) -> Result<usize>
No public source comment is attached to this declaration.
pub fn write( &mut self, bytes: &[u8] ) -> Result<usize>
No public source comment is attached to this declaration.
pub fn write_all(&mut self, bytes: &[u8]) -> Result<()>
No public source comment is attached to this declaration.
pub fn set_io_timeout(&self, timeout: Duration) -> Result<()>
No public source comment is attached to this declaration.
pub fn try_clone( &self ) -> Result<Self>
No public source comment is attached to this declaration.
pub fn shutdown(&self) -> Result<()>
No public source comment is attached to this declaration.
pub fn close( &mut self )
No public source comment is attached to this declaration.
pub const fn is_open( &self ) -> bool
No public source comment is attached to this declaration.
pub const fn peer_addr( &self ) -> SocketAddr
No public source comment is attached to this declaration.
pub const fn remote_addr( &self ) -> IpAddr
No public source comment is attached to this declaration.
pub const fn remote_port( &self ) -> u16
No public source comment is attached to this declaration.
pub fn connect( host: &str, port: u16 ) -> Result<Self>
No public source comment is attached to this declaration.