pub struct UnixDatagram { /* private fields */ }
uds
only.Expand description
An I/O object representing a Unix datagram socket.
Implementations§
Source§impl UnixDatagram
impl UnixDatagram
Sourcepub fn bind<P>(path: P) -> Result<UnixDatagram>
pub fn bind<P>(path: P) -> Result<UnixDatagram>
Creates a new UnixDatagram
bound to the specified path.
Sourcepub fn pair() -> Result<(UnixDatagram, UnixDatagram)>
pub fn pair() -> Result<(UnixDatagram, UnixDatagram)>
Creates an unnamed pair of connected sockets.
This function will create a pair of interconnected Unix sockets for communicating back and forth between one another. Each socket will be associated with the default event loop’s handle.
Sourcepub fn from_std(datagram: UnixDatagram) -> Result<UnixDatagram>
pub fn from_std(datagram: UnixDatagram) -> Result<UnixDatagram>
Consumes a UnixDatagram
in the standard library and returns a
nonblocking UnixDatagram
from this crate.
The returned datagram will be associated with the given event loop
specified by handle
and is ready to perform I/O.
§Panics
This function panics if thread-local runtime is not set.
The runtime is usually set implicitly when this function is called
from a future driven by a tokio runtime, otherwise runtime can be set
explicitly with Handle::enter
function.
Sourcepub fn unbound() -> Result<UnixDatagram>
pub fn unbound() -> Result<UnixDatagram>
Creates a new UnixDatagram
which is not bound to any address.
Sourcepub fn connect<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn connect<P: AsRef<Path>>(&self, path: P) -> Result<()>
Connects the socket to the specified address.
The send
method may be used to send data to the specified address.
recv
and recv_from
will only receive data from that address.
Sourcepub async fn send(&mut self, buf: &[u8]) -> Result<usize>
pub async fn send(&mut self, buf: &[u8]) -> Result<usize>
Sends data on the socket to the socket’s peer.
Sourcepub async fn send_to<P>(&mut self, buf: &[u8], target: P) -> Result<usize>
pub async fn send_to<P>(&mut self, buf: &[u8], target: P) -> Result<usize>
Sends data on the socket to the specified address.
Sourcepub async fn recv_from(&mut self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>
pub async fn recv_from(&mut self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>
Receives data from the socket.
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Returns the local address that this socket is bound to.
Sourcepub fn peer_addr(&self) -> Result<SocketAddr>
pub fn peer_addr(&self) -> Result<SocketAddr>
Returns the address of this socket’s peer.
The connect
method will connect the socket to a peer.
Sourcepub fn take_error(&self) -> Result<Option<Error>>
pub fn take_error(&self) -> Result<Option<Error>>
Returns the value of the SO_ERROR
option.