Struct mio::net::UnixDatagram
source · [−]pub struct UnixDatagram { /* private fields */ }
Expand description
A Unix datagram socket.
Implementations
sourceimpl UnixDatagram
impl UnixDatagram
sourcepub fn bind<P: AsRef<Path>>(path: P) -> Result<UnixDatagram>
pub fn bind<P: AsRef<Path>>(path: P) -> Result<UnixDatagram>
Creates a Unix datagram socket bound to the given path.
sourcepub fn from_std(socket: UnixDatagram) -> UnixDatagram
pub fn from_std(socket: UnixDatagram) -> UnixDatagram
Creates a new UnixDatagram
from a standard net::UnixDatagram
.
This function is intended to be used to wrap a Unix datagram from the standard library in the Mio equivalent. The conversion assumes nothing about the underlying datagram; ; it is left up to the user to set it in non-blocking mode.
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.
sourcepub fn unbound() -> Result<UnixDatagram>
pub fn unbound() -> Result<UnixDatagram>
Creates a Unix Datagram socket which is not bound to any address.
sourcepub fn pair() -> Result<(UnixDatagram, UnixDatagram)>
pub fn pair() -> Result<(UnixDatagram, UnixDatagram)>
Create an unnamed pair of connected sockets.
sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Returns the address of this socket.
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 recv_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>
pub fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>
Receives data from the socket.
On success, returns the number of bytes read and the address from whence the data came.
sourcepub fn recv(&self, buf: &mut [u8]) -> Result<usize>
pub fn recv(&self, buf: &mut [u8]) -> Result<usize>
Receives data from the socket.
On success, returns the number of bytes read.
sourcepub fn send_to<P: AsRef<Path>>(&self, buf: &[u8], path: P) -> Result<usize>
pub fn send_to<P: AsRef<Path>>(&self, buf: &[u8], path: P) -> Result<usize>
Sends data on the socket to the specified address.
On success, returns the number of bytes written.
sourcepub fn send(&self, buf: &[u8]) -> Result<usize>
pub fn send(&self, buf: &[u8]) -> Result<usize>
Sends data on the socket to the socket’s peer.
The peer address may be set by the connect
method, and this method
will return an error if the socket has not already been connected.
On success, returns the number of bytes written.
sourcepub fn take_error(&self) -> Result<Option<Error>>
pub fn take_error(&self) -> Result<Option<Error>>
Returns the value of the SO_ERROR
option.
Trait Implementations
sourceimpl AsRawFd for UnixDatagram
impl AsRawFd for UnixDatagram
sourceimpl Debug for UnixDatagram
impl Debug for UnixDatagram
sourceimpl FromRawFd for UnixDatagram
impl FromRawFd for UnixDatagram
sourceunsafe fn from_raw_fd(fd: RawFd) -> UnixDatagram
unsafe fn from_raw_fd(fd: RawFd) -> UnixDatagram
Converts a RawFd
to a UnixDatagram
.
Notes
The caller is responsible for ensuring that the socket is in non-blocking mode.
sourceimpl IntoRawFd for UnixDatagram
impl IntoRawFd for UnixDatagram
sourcefn into_raw_fd(self) -> RawFd
fn into_raw_fd(self) -> RawFd
Consumes this object, returning the raw underlying file descriptor. Read more
sourceimpl Source for UnixDatagram
impl Source for UnixDatagram
sourcefn register(
&mut self,
registry: &Registry,
token: Token,
interests: Interest
) -> Result<()>
fn register(
&mut self,
registry: &Registry,
token: Token,
interests: Interest
) -> Result<()>
Register self
with the given Registry
instance. Read more
Auto Trait Implementations
impl RefUnwindSafe for UnixDatagram
impl Send for UnixDatagram
impl Sync for UnixDatagram
impl Unpin for UnixDatagram
impl UnwindSafe for UnixDatagram
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more