[][src]Struct interprocess::os::unix::udsocket::UdSocket

pub struct UdSocket { /* fields omitted */ }

A datagram socket in the Unix domain.

All such sockets have the SOCK_DGRAM socket type; in other words, this is the Unix domain version of a UCP socket.

Implementations

impl UdSocket[src]

pub fn bind<'a>(path: impl ToUdSocketPath<'a>) -> Result<Self>[src]

Creates a new server socket at the specified address.

If the socket path exceeds the maximum socket path length (which includes the first 0 byte when using the socket namespace), an error is returned. Errors can also be produced for different reasons, i.e. errors should always be handled regardless of whether the path is known to be short enough or not.

Example

See ToUdSocketPath for an example of using various string types to specify socket paths.

System calls

  • socket
  • bind

pub fn connect<'a>(path: impl ToUdSocketPath<'a>) -> Result<Self>[src]

Connect to a Unix domain socket server at the specified path.

Example

use interprocess::os::unix::udsocket::UdSocket;

let conn = UdSocket::connect("/tmp/example.sock")?;
// Handle the connection to the server

See ToUdSocketPath for an example of using various string types to specify socket paths.

System calls

  • socket
  • connect

pub fn recv(&self, buf: &mut [u8]) -> Result<(usize, bool)>[src]

Receives a single datagram from the socket, returning how much of the buffer was filled out and whether a part of the datagram was discarded because the buffer was too small.

System calls

  • recvmsg
    • Future versions of interprocess may use read instead; for now, this method is a wrapper around recv_vectored.

pub fn recv_vectored(
    &self,
    bufs: &mut [IoSliceMut<'_>]
) -> Result<(usize, bool)>
[src]

Receives a single datagram from the socket, making use of scatter input and returning how much of the buffer was filled out and whether a part of the datagram was discarded because the buffer was too small.

System calls

  • recvmsg
    • Future versions of interprocess may use readv instead; for now, this method is a wrapper around recv_ancillary_vectored.

pub fn recv_ancillary<'a: 'b, 'b>(
    &self,
    buf: &mut [u8],
    abuf: &'b mut AncillaryDataBuf<'a>
) -> Result<(usize, bool, usize, bool)>
[src]

Receives a single datagram and ancillary data from the socket. The return value is in the following order:

  • How many bytes of the datagram were received
  • Whether a part of the datagram was discarded because the buffer was too small
  • How many bytes of ancillary data were received
  • Whether some ancillary data was discarded because the buffer was too small

System calls

  • recvmsg

pub fn recv_ancillary_vectored<'a: 'b, 'b>(
    &self,
    bufs: &mut [IoSliceMut<'_>],
    abuf: &'b mut AncillaryDataBuf<'a>
) -> Result<(usize, bool, usize, bool)>
[src]

Receives a single datagram and ancillary data from the socket, making use of scatter input. The return value is in the following order:

  • How many bytes of the datagram were received
  • Whether a part of the datagram was discarded because the buffer was too small
  • How many bytes of ancillary data were received
  • Whether some ancillary data was discarded because the buffer was too small

System calls

  • recvmsg

pub fn recv_from<'a: 'b, 'b>(
    &self,
    buf: &mut [u8],
    addr_buf: &'b mut UdSocketPath<'a>
) -> Result<(usize, bool)>
[src]

Receives a single datagram and the source address from the socket, returning how much of the buffer was filled out and whether a part of the datagram was discarded because the buffer was too small.

System calls

  • recvmsg
    • Future versions of interprocess may use recvfrom instead; for now, this method is a wrapper around recv_from_vectored.

pub fn recv_from_vectored<'a: 'b, 'b>(
    &self,
    bufs: &mut [IoSliceMut<'_>],
    addr_buf: &'b mut UdSocketPath<'a>
) -> Result<(usize, bool)>
[src]

Receives a single datagram and the source address from the socket, making use of scatter input and returning how much of the buffer was filled out and whether a part of the datagram was discarded because the buffer was too small.

System calls

  • recvmsg

pub fn recv_from_ancillary<'a: 'b, 'b, 'c: 'd, 'd>(
    &self,
    buf: &mut [u8],
    abuf: &'b mut AncillaryDataBuf<'a>,
    addr_buf: &'d mut UdSocketPath<'c>
) -> Result<(usize, bool, usize, bool)>
[src]

Receives a single datagram, ancillary data and the source address from the socket. The return value is in the following order:

  • How many bytes of the datagram were received
  • Whether a part of the datagram was discarded because the buffer was too small
  • How many bytes of ancillary data were received
  • Whether some ancillary data was discarded because the buffer was too small

System calls

  • recvmsg

pub fn recv_from_ancillary_vectored<'a: 'b, 'b, 'c: 'd, 'd>(
    &self,
    bufs: &mut [IoSliceMut<'_>],
    abuf: &'b mut AncillaryDataBuf<'a>,
    addr_buf: &'d mut UdSocketPath<'c>
) -> Result<(usize, bool, usize, bool)>
[src]

Receives a single datagram, ancillary data and the source address from the socket, making use of scatter input. The return value is in the following order:

  • How many bytes of the datagram were received
  • Whether a part of the datagram was discarded because the buffer was too small
  • How many bytes of ancillary data were received
  • Whether some ancillary data was discarded because the buffer was too small

System calls

  • recvmsg

pub fn peek_msg_size(&self) -> Result<usize>[src]

Returns the size of the next datagram available on the socket without discarding it.

This method is only available on Linux since kernel version 2.2. On lower kernel versions, it will fail; on other platforms, it's absent and thus any usage of it will result in a compile-time error.

System calls

  • recv

pub fn send(&self, buf: &[u8]) -> Result<usize>[src]

Sends a datagram into the socket.

System calls

  • sendmsg
    • Future versions of interprocess may use write instead; for now, this method is a wrapper around send_vectored.

pub fn send_vectored(&self, bufs: &[IoSlice<'_>]) -> Result<usize>[src]

Sends a datagram into the socket, making use of gather output for the main data.

System calls

  • sendmsg
    • Future versions of interprocess may use writev instead; for now, this method is a wrapper around send_ancillary_vectored.

pub fn send_ancillary<'a>(
    &self,
    buf: &[u8],
    ancillary_data: impl IntoIterator<Item = AncillaryData<'a>>
) -> Result<(usize, usize)>
[src]

Sends a datagram and ancillary data into the socket.

The ancillary data buffer is automatically converted from the supplied value, if possible. For that reason, slices and Vecs of AncillaryData can be passed directly.

System calls

  • sendmsg

pub fn send_ancillary_vectored<'a>(
    &self,
    bufs: &[IoSlice<'_>],
    ancillary_data: impl IntoIterator<Item = AncillaryData<'a>>
) -> Result<(usize, usize)>
[src]

Sends a datagram and ancillary data into the socket, making use of gather output for the main data.

The ancillary data buffer is automatically converted from the supplied value, if possible. For that reason, slices and Vecs of AncillaryData can be passed directly.

System calls

  • sendmsg

Trait Implementations

impl AsRawFd for UdSocket[src]

impl Debug for UdSocket[src]

impl FromRawFd for UdSocket[src]

impl IntoRawFd for UdSocket[src]

impl ReliableReadMsg for UdSocket[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.