pub struct ScmSocket<T: AsRawDescriptor> {
pub(in sys) socket: T,
}
Expand description
Trait for file descriptors can send and receive socket control messages via sendmsg
and
recvmsg
.
On Linux, this uses MSG_NOSIGNAL to avoid triggering signals. On MacOS, this sets the SO_NOSIGPIPE option on the file descriptor to avoid triggering signals.
Fields§
§socket: T
Implementations§
source§impl<T: AsRawDescriptor> ScmSocket<T>
impl<T: AsRawDescriptor> ScmSocket<T>
sourcepub fn send_with_fds(&self, buf: &[u8], fds: &[RawFd]) -> Result<usize>
pub fn send_with_fds(&self, buf: &[u8], fds: &[RawFd]) -> Result<usize>
Sends the given data and file descriptors over the socket.
On success, returns the number of bytes sent.
The error is constructed via std::io::Error::last_os_error()
.
§Arguments
buf
- A buffer of data to send on thesocket
.fds
- A list of file descriptors to be sent.
sourcepub fn send_vectored_with_fds(
&self,
bufs: &[impl AsIobuf],
fds: &[RawFd]
) -> Result<usize>
pub fn send_vectored_with_fds( &self, bufs: &[impl AsIobuf], fds: &[RawFd] ) -> Result<usize>
Sends the given data and file descriptors over the socket.
On success, returns the number of bytes sent.
The error is constructed via std::io::Error::last_os_error()
.
§Arguments
bufs
- A slice of buffers of data to send on thesocket
.fds
- A list of file descriptors to be sent.
sourcepub fn recv_with_fds(
&self,
buf: &mut [u8],
max_descriptors: usize
) -> Result<(usize, Vec<SafeDescriptor>)>
pub fn recv_with_fds( &self, buf: &mut [u8], max_descriptors: usize ) -> Result<(usize, Vec<SafeDescriptor>)>
Receives data and file descriptors from the socket.
On success, returns the number of bytes and file descriptors received as a tuple
(bytes count, descriptors)
.
The error is constructed via std::io::Error::last_os_error()
.
§Arguments
buf
- A buffer to store received data.max_descriptors
- Maximum number of file descriptors to receive.
sourcepub fn recv_vectored_with_fds(
&self,
bufs: &mut [IoSliceMut<'_>],
max_descriptors: usize
) -> Result<(usize, Vec<SafeDescriptor>)>
pub fn recv_vectored_with_fds( &self, bufs: &mut [IoSliceMut<'_>], max_descriptors: usize ) -> Result<(usize, Vec<SafeDescriptor>)>
Receives data and file descriptors from the socket.
On success, returns the number of bytes and file descriptors received as a tuple
(bytes count, files count)
.
The error is constructed via std::io::Error::last_os_error()
.
§Arguments
bufs
- A slice of buffers to store received data.max_descriptors
- Maximum number of file descriptors to receive.
sourcepub fn recv_with_file(&self, buf: &mut [u8]) -> Result<(usize, Option<File>)>
pub fn recv_with_file(&self, buf: &mut [u8]) -> Result<(usize, Option<File>)>
Receives data and potentially a file descriptor from the socket.
On success, returns the number of bytes and an optional file descriptor.
The error is constructed via std::io::Error::last_os_error()
.
§Arguments
buf
- A buffer to receive data from the socket.vm
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Returns the inner object, destroying the ScmSocket.