Struct nex_socket::AsyncTcpStream
source · pub struct AsyncTcpStream { /* private fields */ }
Expand description
Async TCP Stream.
Implementations§
source§impl AsyncTcpStream
impl AsyncTcpStream
sourcepub async fn connect(addr: SocketAddr) -> Result<Self>
pub async fn connect(addr: SocketAddr) -> Result<Self>
Connect to a remote address.
sourcepub async fn connect_timeout(
addr: &SocketAddr,
timeout: Duration
) -> Result<Self>
pub async fn connect_timeout( addr: &SocketAddr, timeout: Duration ) -> Result<Self>
Connect to a remote address with timeout.
sourcepub async fn local_addr(&self) -> Result<SocketAddr>
pub async fn local_addr(&self) -> Result<SocketAddr>
Get local address.
sourcepub async fn peer_addr(&self) -> Result<SocketAddr>
pub async fn peer_addr(&self) -> Result<SocketAddr>
Get peer address.
sourcepub async fn write_all(&self, buf: &[u8]) -> Result<()>
pub async fn write_all(&self, buf: &[u8]) -> Result<()>
Attempts to write an entire buffer into this writer.
sourcepub async fn read_to_end(&self, buf: &mut Vec<u8>) -> Result<usize>
pub async fn read_to_end(&self, buf: &mut Vec<u8>) -> Result<usize>
Read all bytes until EOF in this source, placing them into buf.
sourcepub async fn read_to_end_timeout(
&self,
buf: &mut Vec<u8>,
timeout: Duration
) -> Result<usize>
pub async fn read_to_end_timeout( &self, buf: &mut Vec<u8>, timeout: Duration ) -> Result<usize>
Read all bytes until EOF in this source, placing them into buf. This ignore io::Error on read_to_end because it is expected when reading response. If no response is received, and io::Error is occurred, return Err.
sourcepub async fn take_error(&self) -> Result<Option<Error>>
pub async fn take_error(&self) -> Result<Option<Error>>
Get the value of the SO_ERROR
option on this socket.
sourcepub async fn try_clone(&self) -> Result<Self>
pub async fn try_clone(&self) -> Result<Self>
Creates a new independently owned handle to the underlying socket.
sourcepub async fn set_read_timeout(&self, dur: Option<Duration>) -> Result<()>
pub async fn set_read_timeout(&self, dur: Option<Duration>) -> Result<()>
Sets the read timeout to the timeout specified.
sourcepub async fn set_write_timeout(&self, dur: Option<Duration>) -> Result<()>
pub async fn set_write_timeout(&self, dur: Option<Duration>) -> Result<()>
Sets the write timeout to the timeout specified.
sourcepub async fn read_timeout(&self) -> Result<Option<Duration>>
pub async fn read_timeout(&self) -> Result<Option<Duration>>
Gets the read timeout of this socket.
sourcepub async fn write_timeout(&self) -> Result<Option<Duration>>
pub async fn write_timeout(&self) -> Result<Option<Duration>>
Gets the write timeout of this socket.
sourcepub async fn set_nodelay(&self, nodelay: bool) -> Result<()>
pub async fn set_nodelay(&self, nodelay: bool) -> Result<()>
Sets the value of the TCP_NODELAY
option on this socket.
sourcepub async fn nodelay(&self) -> Result<bool>
pub async fn nodelay(&self) -> Result<bool>
Gets the value of the TCP_NODELAY
option on this socket.
sourcepub async fn set_ttl(&self, ttl: u32) -> Result<()>
pub async fn set_ttl(&self, ttl: u32) -> Result<()>
Sets the value for the IP_TTL option on this socket.
sourcepub async fn set_nonblocking(&self, nonblocking: bool) -> Result<()>
pub async fn set_nonblocking(&self, nonblocking: bool) -> Result<()>
Moves this TCP stream into or out of nonblocking mode.
Trait Implementations§
source§impl Clone for AsyncTcpStream
impl Clone for AsyncTcpStream
source§fn clone(&self) -> AsyncTcpStream
fn clone(&self) -> AsyncTcpStream
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more