pub struct TcpStream { /* private fields */ }
Expand description
A single TCP connection.
This type and references to it implement the AsyncRead
and AsyncWrite
traits. For more on using this type, see the AsyncReadExt
and AsyncWriteExt
traits.
Implementations§
Source§impl TcpStream
impl TcpStream
Sourcepub fn connect_from_raw(
socket: impl IntoRawFd,
addr: SocketAddr,
) -> Result<TcpConnector>
pub fn connect_from_raw( socket: impl IntoRawFd, addr: SocketAddr, ) -> Result<TcpConnector>
Creates a new TcpStream
connected to a specific socket address from an existing socket
descriptor.
This function returns a future which resolves to an io::Result<TcpStream>
.
Sourcepub fn connect(addr: SocketAddr) -> Result<TcpConnector>
pub fn connect(addr: SocketAddr) -> Result<TcpConnector>
Creates a new TcpStream
connected to a specific socket address.
This function returns a future which resolves to an io::Result<TcpStream>
.
Methods from Deref<Target = EventedFd<TcpStream>>§
Sourcepub fn poll_readable(&self, cx: &mut Context<'_>) -> Poll<Result<(), Status>>
pub fn poll_readable(&self, cx: &mut Context<'_>) -> Poll<Result<(), Status>>
Tests to see if this resource is ready to be read from. If it is not, it arranges for the current task to receive a notification when a “readable” signal arrives.
Sourcepub fn poll_writable(&self, cx: &mut Context<'_>) -> Poll<Result<(), Status>>
pub fn poll_writable(&self, cx: &mut Context<'_>) -> Poll<Result<(), Status>>
Tests to see if this resource is ready to be written to. If it is not, it arranges for the current task to receive a notification when a “writable” signal arrives.
pub fn as_ref(&self) -> &T
Sourcepub fn need_read(&self, cx: &mut Context<'_>)
pub fn need_read(&self, cx: &mut Context<'_>)
Arranges for the current task to receive a notification when a “readable” signal arrives.
Sourcepub fn need_write(&self, cx: &mut Context<'_>)
pub fn need_write(&self, cx: &mut Context<'_>)
Arranges for the current task to receive a notification when a “writable” signal arrives.
Trait Implementations§
Source§impl AsyncRead for TcpStream
impl AsyncRead for TcpStream
Source§impl AsyncWrite for TcpStream
impl AsyncWrite for TcpStream
Source§fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize>>
buf
into the object. Read moreSource§fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<()>>
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<()>>
Auto Trait Implementations§
impl Freeze for TcpStream
impl !RefUnwindSafe for TcpStream
impl Send for TcpStream
impl Sync for TcpStream
impl Unpin for TcpStream
impl !UnwindSafe for TcpStream
Blanket Implementations§
§impl<R> AsyncReadExt for Rwhere
R: AsyncRead + ?Sized,
impl<R> AsyncReadExt for Rwhere
R: AsyncRead + ?Sized,
§fn chain<R>(self, next: R) -> Chain<Self, R>where
Self: Sized,
R: AsyncRead,
fn chain<R>(self, next: R) -> Chain<Self, R>where
Self: Sized,
R: AsyncRead,
§fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>where
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>where
Self: Unpin,
buf
in asynchronous
manner, returning a future type. Read more§fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectored<'a, Self>where
Self: Unpin,
fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectored<'a, Self>where
Self: Unpin,
AsyncRead
into bufs
using vectored
IO operations. Read more§fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>where
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>where
Self: Unpin,
buf
,
returning an error if end of file (EOF) is hit sooner. Read more§fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>where
Self: Unpin,
fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>where
Self: Unpin,
AsyncRead
. Read more§fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToString<'a, Self>where
Self: Unpin,
fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToString<'a, Self>where
Self: Unpin,
AsyncRead
. Read more§impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
§fn flush(&mut self) -> Flush<'_, Self>where
Self: Unpin,
fn flush(&mut self) -> Flush<'_, Self>where
Self: Unpin,
AsyncWrite
. Read more§fn close(&mut self) -> Close<'_, Self>where
Self: Unpin,
fn close(&mut self) -> Close<'_, Self>where
Self: Unpin,
AsyncWrite
.§fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self>where
Self: Unpin,
fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self>where
Self: Unpin,
buf
into the object. Read more§fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectored<'a, Self>where
Self: Unpin,
fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectored<'a, Self>where
Self: Unpin,
bufs
into the object using vectored
IO operations. Read more