/// Reads all bytes from the socket into the given scatter/gather vectors with optional
/// attached files. Will loop until all data has been transferred.
///
/// 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 fds]) on success
/// * - 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 all bytes from the socket into the given scatter/gather vectors with optional
attached files. Will loop until all data has been transferred.

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 all bytes from the socket into the given scatter / gather vectors with optional attached files . Will loop until all data has been transferred . 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_all(
        &mut self,
        iovs: &mut [iovec],
    ) -> Result<(usize, Option<Vec<File>>)> {
        let mut data_read = 0;
        let mut data_total = 0;
        let mut rfds = None;
        let iov_lens: Vec<usize> = iovs.iter().map(|iov| iov.iov_len).collect();
        for len in &iov_lens {
            data_total += len;
        }
        while (data_total - data_read) > 0 {
            let (nr_skip, offset) = get_sub_iovs_offset(&iov_lens, data_read);
            let iov = &mut iovs[nr_skip];
            let mut data = [
                &[iovec {
                    iov_base: (iov.iov_base as usize + offset) as *mut c_void,
                    iov_len: iov.iov_len - offset,
                }],
                &iovs[(nr_skip + 1)..],
            ]
            .concat();
            let res = self.recv_into_iovec(&mut data);
            match res {
                Ok((0, _)) => return Ok((data_read, rfds)),
                Ok((n, fds)) => {
                    if data_read == 0 {
                        rfds = fds;
                    }
                    data_read += n;
                }
                Err(e) => match e {
                    Error::SocketRetry(_) => {}
                    _ => return Err(e),
                },
            }
        }
        Ok((data_read, rfds))
    }
pub unsafe fn recv_into_iovec_all ( & mut self , iovs : & mut [ iovec ] , ) -> Result < ( usize , Option < Vec < File > > ) > { let mut data_read = 0 ; let mut data_total = 0 ; let mut rfds = None ; let iov_lens : Vec < usize > = iovs . iter ( ) . map ( | iov | iov . iov_len ) . collect ( ) ; for len in & iov_lens { data_total += len ; } while ( data_total - data_read ) > 0 { let ( nr_skip , offset ) = get_sub_iovs_offset ( & iov_lens , data_read ) ; let iov = & mut iovs [ nr_skip ] ; let mut data = [ & [ iovec { iov_base : ( iov . iov_base as usize + offset ) as * mut c_void , iov_len : iov . iov_len - offset , } ] , & iovs [ ( nr_skip + 1 ) .. ] , ] . concat ( ) ; let res = self . recv_into_iovec ( & mut data ) ; match res { Ok ( ( 0 , _ ) ) => return Ok ( ( data_read , rfds ) ) , Ok ( ( n , fds ) ) => { if data_read == 0 { rfds = fds ; } data_read += n ; } Err ( e ) => match e { Error :: SocketRetry ( _ ) => { } _ => return Err ( e ) , } , } } Ok ( ( data_read , rfds ) ) }
Reads all bytes from the socket into the given scatter/gather vectors with optional
attached files.
Reads all bytes from the socket into the given scatter / gather vectors with optional attached files .
&mut self
iovs
&mut [iovec]
return:
- (number of bytes received, [received fds]) on success
- SocketBroken: the underline socket is broken.
- SocketError: other socket related errors.
- ( number of bytes received [ received fds ] ) on success - 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 .