Struct async_net::unix::UnixStream [−][src]
pub struct UnixStream { /* fields omitted */ }
Expand description
A Unix connection.
A UnixStream
can be created by connect
ing to an endpoint or by
accept
ing an incoming connection.
UnixStream
is a bidirectional stream that implements traits [AsyncRead
] and
[AsyncWrite
].
Cloning a UnixStream
creates another handle to the same socket. The socket will be closed
when all handles to it are dropped. The reading and writing portions of the connection can also
be shut down individually with the shutdown()
method.
Examples
use async_net::unix::UnixStream; use futures_lite::prelude::*; let mut stream = UnixStream::connect("/tmp/socket").await?; stream.write_all(b"hello").await?; let mut buf = vec![0u8; 1024]; let n = stream.read(&mut buf).await?;
Implementations
Creates a Unix connection to given path.
Examples
use async_net::unix::UnixStream; let stream = UnixStream::connect("/tmp/socket").await?;
Creates a pair of connected Unix sockets.
Examples
use async_net::unix::UnixStream; let (stream1, stream2) = UnixStream::pair()?;
Returns the local address this socket is connected to.
Examples
use async_net::unix::UnixStream; let stream = UnixStream::connect("/tmp/socket").await?; println!("Local address is {:?}", stream.local_addr()?);
Returns the remote address this socket is connected to.
Examples
use async_net::unix::UnixStream; let stream = UnixStream::connect("/tmp/socket").await?; println!("Connected to {:?}", stream.peer_addr()?);
Shuts down the read half, write half, or both halves of this connection.
This method will cause all pending and future I/O in the given directions to return
immediately with an appropriate value (see the documentation of Shutdown
).
use async_net::{Shutdown, unix::UnixStream}; let stream = UnixStream::connect("/tmp/socket").await?; stream.shutdown(Shutdown::Both)?;
Trait Implementations
Attempt to read from the AsyncRead
into buf
. Read more
Performs the conversion.
Performs the conversion.
Performs the conversion.
Auto Trait Implementations
Blanket Implementations
Reads some bytes from the byte stream. Read more
fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self> where
Self: Unpin,
fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self> where
Self: Unpin,
fn read_to_end(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEndFuture<'a, Self> where
Self: Unpin,
fn read_to_end(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEndFuture<'a, Self> where
Self: Unpin,
fn read_to_string(
&'a mut self,
buf: &'a mut String
) -> ReadToStringFuture<'a, Self> where
Self: Unpin,
fn read_to_string(
&'a mut self,
buf: &'a mut String
) -> ReadToStringFuture<'a, Self> where
Self: Unpin,
Reads the exact number of bytes required to fill buf
. Read more
Creates an adapter which will read at most limit
bytes from it. Read more
Creates an adapter which will chain this stream with another. Read more
Writes some bytes into the byte stream. Read more
fn write_vectored(
&'a mut self,
bufs: &'a [IoSlice<'a>]
) -> WriteVectoredFuture<'a, Self> where
Self: Unpin,
fn write_vectored(
&'a mut self,
bufs: &'a [IoSlice<'a>]
) -> WriteVectoredFuture<'a, Self> where
Self: Unpin,
Writes an entire buffer into the byte stream. Read more
Flushes the stream to ensure that all buffered contents reach their destination. Read more
Closes the writer. Read more
Mutably borrows from an owned value. Read more