/// Reads bytes from the socket into a new buffer with optional attached
/// files. Received file descriptors are set close-on-exec and converted to `File`.
///
/// # Return:
/// * - (number of bytes received, buf, [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.
Reads bytes from the socket into a new buffer with optional attached
files. Received file descriptors are set close-on-exec and converted to `File`.
Reads bytes from the socket into a new buffer with optional attached files . Received file descriptors are set close - on - exec and converted to ` File ` .
pub fn recv_into_buf(
        &mut self,
        buf_size: usize,
    ) -> Result<(usize, Vec<u8>, Option<Vec<File>>)> {
        let mut buf = vec![0u8; buf_size];
        let (bytes, files) = {
            let mut iovs = [iovec {
                iov_base: buf.as_mut_ptr() as *mut c_void,
                iov_len: buf_size,
            }];
            // Safe because we own buf and it's safe to fill a byte array with arbitrary data.
            unsafe { self.recv_into_iovec(&mut iovs)? }
        };
        Ok((bytes, buf, files))
    }
pub fn recv_into_buf ( & mut self , buf_size : usize , ) -> Result < ( usize , Vec < u8 > , Option < Vec < File > > ) > { let mut buf = vec ! [ 0u8 buf_size ] ; let ( bytes , files ) = { let mut iovs = [ iovec { iov_base : buf . as_mut_ptr ( ) as * mut c_void , iov_len : buf_size , } ] ; // Safe because we own buf and it's safe to fill a byte array with arbitrary data. unsafe { self . recv_into_iovec ( & mut iovs ) ? } } ; Ok ( ( bytes , buf , files ) ) }
Reads bytes from the socket into a new buffer with optional attached
files.
Reads bytes from the socket into a new buffer with optional attached files .
&mut self
buf_size
usize
return:
- (number of bytes received, buf, [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 buf [ 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 .