/// Sends a header-only message with optional attached file descriptors.
///
/// # Return:
/// * - number of bytes sent on success
/// * - SocketRetry: temporary error caused by signals or short of resources.
/// * - SocketBroken: the underline socket is broken.
/// * - SocketError: other socket related errors.
/// * - PartialMessage: received a partial message.
Sends a header-only message with optional attached file descriptors.
Sends a header - only message with optional attached file descriptors .
pub fn send_header(&mut self, hdr: &MsgHeader, fds: Option<&[RawFd]>) -> Result<()> {
        // Safe because there can't be other mutable referance to hdr.
        let iovs = unsafe {
            [slice::from_raw_parts(
                hdr as *const MsgHeader as *const u8,
                mem::size_of::<MsgHeader>(),
            )]
        };
        let bytes = self.send_iovec_all(&iovs[..], fds)?;
        if bytes != mem::size_of::<MsgHeader>() {
            return Err(Error::PartialMessage);
        }
        Ok(())
    }
pub fn send_header ( & mut self , hdr : & MsgHeader , fds : Option < & [ RawFd ] > ) -> Result < ( ) > { // Safe because there can't be other mutable referance to hdr. let iovs = unsafe { [ slice :: from_raw_parts ( hdr as * const MsgHeader as * const u8 , mem :: size_of :: < MsgHeader > ( ) , ) ] } ; let bytes = self . send_iovec_all ( & iovs [ .. ] , fds ) ? ; if bytes != mem :: size_of :: < MsgHeader > ( ) { return Err ( Error :: PartialMessage ) ; } Ok ( ( ) ) }
Sends a header-only message with optional attached file descriptors.
Sends a header - only message with optional attached file descriptors .
&mut self
hdr
&MsgHeader
fds
Option<&[RawFd]>
return:
- number of bytes sent on success
- SocketRetry: temporary error caused by signals or short of resources.
- SocketBroken: the underline socket is broken.
- SocketError: other socket related errors.
- PartialMessage: received a partial message.
- number of bytes sent on success - SocketRetry : temporary error caused by signals or short of resources . - SocketBroken : the underline socket is broken . - SocketError : other socket related errors . - PartialMessage : received a partial message .