/// Sends all bytes from scatter-gather vectors over the socket with optional attached file
/// descriptors. Will loop until all data has been transfered.
///
/// # Return:
/// * - number of bytes sent on success
/// * - SocketBroken: the underline socket is broken.
/// * - SocketError: other socket related errors.
Sends all bytes from scatter-gather vectors over the socket with optional attached file
descriptors. Will loop until all data has been transfered.
Sends all bytes from scatter - gather vectors over the socket with optional attached file descriptors . Will loop until all data has been transfered .
pub fn send_iovec_all(&mut self, iovs: &[&[u8]], fds: Option<&[RawFd]>) -> Result<usize> {
        let mut data_sent = 0;
        let mut data_total = 0;
        let iov_lens: Vec<usize> = iovs.iter().map(|iov| iov.len()).collect();
        for len in &iov_lens {
            data_total += len;
        }
        while (data_total - data_sent) > 0 {
            let (nr_skip, offset) = get_sub_iovs_offset(&iov_lens, data_sent);
            let iov = &iovs[nr_skip][offset..];
            let data = &[&[iov], &iovs[(nr_skip + 1)..]].concat();
            let sfds = if data_sent == 0 { fds } else { None };
            let sent = self.send_iovec(data, sfds);
            match sent {
                Ok(0) => return Ok(data_sent),
                Ok(n) => data_sent += n,
                Err(e) => match e {
                    Error::SocketRetry(_) => {}
                    _ => return Err(e),
                },
            }
        }
        Ok(data_sent)
    }
pub fn send_iovec_all ( & mut self , iovs : & [ & [ u8 ] ] , fds : Option < & [ RawFd ] > ) -> Result < usize > { let mut data_sent = 0 ; let mut data_total = 0 ; let iov_lens : Vec < usize > = iovs . iter ( ) . map ( | iov | iov . len ( ) ) . collect ( ) ; for len in & iov_lens { data_total += len ; } while ( data_total - data_sent ) > 0 { let ( nr_skip , offset ) = get_sub_iovs_offset ( & iov_lens , data_sent ) ; let iov = & iovs [ nr_skip ] [ offset .. ] ; let data = & [ & [ iov ] , & iovs [ ( nr_skip + 1 ) .. ] ] . concat ( ) ; let sfds = if data_sent == 0 { fds } else { None } ; let sent = self . send_iovec ( data , sfds ) ; match sent { Ok ( 0 ) => return Ok ( data_sent ) , Ok ( n ) => data_sent += n , Err ( e ) => match e { Error :: SocketRetry ( _ ) => { } _ => return Err ( e ) , } , } } Ok ( data_sent ) }
Sends all bytes from scatter-gather vectors over the socket with optional attached file
descriptors.
Sends all bytes from scatter - gather vectors over the socket with optional attached file descriptors .
&mut self
iovs
&[&[u8]]
fds
Option<&[RawFd]>
return:
- number of bytes sent on success
- SocketBroken: the underline socket is broken.
- SocketError: other socket related errors.
- number of bytes sent on success - SocketBroken : the underline socket is broken . - SocketError : other socket related errors .