pub unsafe fn recv_into_iovec(
        &mut self,
        iovs: &mut [iovec],
    ) -> Result<(usize, Option<Vec<File>>)> {
        let mut fd_array = vec![0; MAX_ATTACHED_FD_ENTRIES];
        let (bytes, fds) = self.sock.recv_with_fds(iovs, &mut fd_array)?;

        let files = match fds {
            0 => None,
            n => {
                let files = fd_array
                    .iter()
                    .take(n)
                    .map(|fd| {
                        // Safe because we have the ownership of `fd`.
                        unsafe { File::from_raw_fd(*fd) }
                    })
                    .collect();
                Some(files)
            }
        };

        Ok((bytes, files))
    }
/// Reads bytes from the socket into the given scatter/gather vectors with optional attached
/// file.
///
/// The underlying communication channel is a Unix domain socket in STREAM mode. It's a little
/// tricky to pass file descriptors through such a communication channel. Let's assume that a
/// sender sending a message with some file descriptors attached. To successfully receive those
/// attached file descriptors, the receiver must obey following rules:
///   1) file descriptors are attached to a message.
///   2) message(packet) boundaries must be respected on the receive side.
/// In other words, recvmsg() operations must not cross the packet boundary, otherwise the
/// attached file descriptors will get lost.
/// Note that this function wraps received file descriptors as `File`.
///
/// # Return:
/// * - (number of bytes received, [received files]) on success
/// * - SocketRetry: temporary error caused by signals or short of resources.
/// * - SocketBroken: the underline socket is broken.
/// * - SocketError: other socket related errors.
///
/// # Safety
///
/// It is the callers responsibility to ensure it is safe for arbitrary data to be
/// written to the iovec pointers.
Reads bytes from the socket into the given scatter/gather vectors with optional attached
file.

The underlying communication channel is a Unix domain socket in STREAM mode. It's a little
tricky to pass file descriptors through such a communication channel. Let's assume that a
sender sending a message with some file descriptors attached. To successfully receive those
attached file descriptors, the receiver must obey following rules:
1) file descriptors are attached to a message.
2) message(packet) boundaries must be respected on the receive side.
In other words, recvmsg() operations must not cross the packet boundary, otherwise the
attached file descriptors will get lost.
Note that this function wraps received file descriptors as `File`.
Reads bytes from the socket into the given scatter / gather vectors with optional attached file . The underlying communication channel is a Unix domain socket in STREAM mode . It ' s a little tricky to pass file descriptors through such a communication channel . Let ' s assume that a sender sending a message with some file descriptors attached . To successfully receive those attached file descriptors the receiver must obey following rules : 1 ) file descriptors are attached to a message . 2 ) message ( packet ) boundaries must be respected on the receive side . In other words recvmsg () operations must not cross the packet boundary otherwise the attached file descriptors will get lost . Note that this function wraps received file descriptors as ` File ` .
pub unsafe fn recv_into_iovec(
        &mut self,
        iovs: &mut [iovec],
    ) -> Result<(usize, Option<Vec<File>>)> {
        let mut fd_array = vec![0; MAX_ATTACHED_FD_ENTRIES];
        let (bytes, fds) = self.sock.recv_with_fds(iovs, &mut fd_array)?;
        let files = match fds {
            0 => None,
            n => {
                let files = fd_array
                    .iter()
                    .take(n)
                    .map(|fd| {
                        // Safe because we have the ownership of `fd`.
                        unsafe { File::from_raw_fd(*fd) }
                    })
                    .collect();
                Some(files)
            }
        };
        Ok((bytes, files))
    }
pub unsafe fn recv_into_iovec ( & mut self , iovs : & mut [ iovec ] , ) -> Result < ( usize , Option < Vec < File > > ) > { let mut fd_array = vec ! [ 0 MAX_ATTACHED_FD_ENTRIES ] ; let ( bytes , fds ) = self . sock . recv_with_fds ( iovs , & mut fd_array ) ? ; let files = match fds { 0 => None , n => { let files = fd_array . iter ( ) . take ( n ) . map ( | fd | { // Safe because we have the ownership of `fd`. unsafe { File :: from_raw_fd ( * fd ) } } ) . collect ( ) ; Some ( files ) } } ; Ok ( ( bytes , files ) ) }
Reads bytes from the socket into the given scatter/gather vectors with optional attached
file.
Reads bytes from the socket into the given scatter / gather vectors with optional attached file .
&mut self
iovs
&mut [iovec]
&mut self
iovs
&mut [iovec]
return:
- (number of bytes received, [received files]) on success
- SocketRetry: temporary error caused by signals or short of resources.
- SocketBroken: the underline socket is broken.
- SocketError: other socket related errors.
- ( number of bytes received [ received files ] ) on success - SocketRetry : temporary error caused by signals or short of resources . - SocketBroken : the underline socket is broken . - SocketError : other socket related errors .
safety
It is the callers responsibility to ensure it is safe for arbitrary data to be
written to the iovec pointers.
It is the callers responsibility to ensure it is safe for arbitrary data to be written to the iovec pointers .