[−][src]Struct interprocess::os::unix::udsocket::UdSocket
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 useread
instead; for now, this method is a wrapper aroundrecv_vectored
.
- Future versions of
pub fn recv_vectored(
&self,
bufs: &mut [IoSliceMut<'_>]
) -> Result<(usize, bool)>
[src]
&self,
bufs: &mut [IoSliceMut<'_>]
) -> Result<(usize, bool)>
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 usereadv
instead; for now, this method is a wrapper aroundrecv_ancillary_vectored
.
- Future versions of
pub fn recv_ancillary<'a: 'b, 'b>(
&self,
buf: &mut [u8],
abuf: &'b mut AncillaryDataBuf<'a>
) -> Result<(usize, bool, usize, bool)>
[src]
&self,
buf: &mut [u8],
abuf: &'b mut AncillaryDataBuf<'a>
) -> Result<(usize, bool, usize, bool)>
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]
&self,
bufs: &mut [IoSliceMut<'_>],
abuf: &'b mut AncillaryDataBuf<'a>
) -> Result<(usize, bool, usize, bool)>
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]
&self,
buf: &mut [u8],
addr_buf: &'b mut UdSocketPath<'a>
) -> Result<(usize, bool)>
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 userecvfrom
instead; for now, this method is a wrapper aroundrecv_from_vectored
.
- Future versions of
pub fn recv_from_vectored<'a: 'b, 'b>(
&self,
bufs: &mut [IoSliceMut<'_>],
addr_buf: &'b mut UdSocketPath<'a>
) -> Result<(usize, bool)>
[src]
&self,
bufs: &mut [IoSliceMut<'_>],
addr_buf: &'b mut UdSocketPath<'a>
) -> Result<(usize, bool)>
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]
&self,
buf: &mut [u8],
abuf: &'b mut AncillaryDataBuf<'a>,
addr_buf: &'d mut UdSocketPath<'c>
) -> Result<(usize, bool, usize, bool)>
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]
&self,
bufs: &mut [IoSliceMut<'_>],
abuf: &'b mut AncillaryDataBuf<'a>,
addr_buf: &'d mut UdSocketPath<'c>
) -> Result<(usize, bool, usize, bool)>
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 usewrite
instead; for now, this method is a wrapper aroundsend_vectored
.
- Future versions of
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 usewritev
instead; for now, this method is a wrapper aroundsend_ancillary_vectored
.
- Future versions of
pub fn send_ancillary<'a>(
&self,
buf: &[u8],
ancillary_data: impl IntoIterator<Item = AncillaryData<'a>>
) -> Result<(usize, usize)>
[src]
&self,
buf: &[u8],
ancillary_data: impl IntoIterator<Item = AncillaryData<'a>>
) -> Result<(usize, usize)>
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 Vec
s 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]
&self,
bufs: &[IoSlice<'_>],
ancillary_data: impl IntoIterator<Item = AncillaryData<'a>>
) -> Result<(usize, usize)>
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 Vec
s 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]
unsafe fn from_raw_fd(fd: c_int) -> Self
[src]
impl IntoRawFd for UdSocket
[src]
fn into_raw_fd(self) -> c_int
[src]
impl ReliableReadMsg for UdSocket
[src]
Auto Trait Implementations
impl RefUnwindSafe for UdSocket
impl Send for UdSocket
impl Sync for UdSocket
impl Unpin for UdSocket
impl UnwindSafe for UdSocket
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,