pub fn recv_data(&mut self, len: usize) -> Result<(usize, Vec<u8>)> {
        let mut rbuf = vec![0u8; len];
        let mut iovs = [iovec {
            iov_base: rbuf.as_mut_ptr() as *mut c_void,
            iov_len: len,
        }];
        // Safe because we own rbuf and it's safe to fill a byte array with arbitrary data.
        let (bytes, _) = self.sock.recv_with_fds(&mut iovs, &mut [])?;
        Ok((bytes, rbuf))
    }
/// Reads bytes from the socket into the given scatter/gather vectors.
///
/// # Return:
/// * - (number of bytes received, buf) on success
/// * - SocketRetry: temporary error caused by signals or short of resources.
/// * - SocketBroken: the underline socket is broken.
/// * - SocketError: other socket related errors.
Reads bytes from the socket into the given scatter/gather vectors.
Reads bytes from the socket into the given scatter / gather vectors .
pub fn recv_data(&mut self, len: usize) -> Result<(usize, Vec<u8>)> {
        let mut rbuf = vec![0u8; len];
        let mut iovs = [iovec {
            iov_base: rbuf.as_mut_ptr() as *mut c_void,
            iov_len: len,
        }];
        // Safe because we own rbuf and it's safe to fill a byte array with arbitrary data.
        let (bytes, _) = self.sock.recv_with_fds(&mut iovs, &mut [])?;
        Ok((bytes, rbuf))
    }
pub fn recv_data ( & mut self , len : usize ) -> Result < ( usize , Vec < u8 > ) > { let mut rbuf = vec ! [ 0u8 len ] ; let mut iovs = [ iovec { iov_base : rbuf . as_mut_ptr ( ) as * mut c_void , iov_len : len , } ] ; // Safe because we own rbuf and it's safe to fill a byte array with arbitrary data. let ( bytes , _ ) = self . sock . recv_with_fds ( & mut iovs , & mut [ ] ) ? ; Ok ( ( bytes , rbuf ) ) }
Reads bytes from the socket into the given scatter/gather vectors.
Reads bytes from the socket into the given scatter / gather vectors .
&mut self
len
usize
&mut self
len
usize
return:
- (number of bytes received, buf) 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 buf ) on success - SocketRetry : temporary error caused by signals or short of resources . - SocketBroken : the underline socket is broken . - SocketError : other socket related errors .