Function nix::sys::socket::recvmmsg

source ·
pub fn recvmmsg<'a, XS, S, I>(
    fd: RawFd,
    data: &'a mut MultiHeaders<S>,
    slices: XS,
    flags: MsgFlags,
    timeout: Option<TimeSpec>
) -> Result<MultiResults<'a, S>>where
    XS: IntoIterator<Item = &'a I>,
    I: AsRef<[IoSliceMut<'a>]> + 'a,
Available on crate features socket and uio only.
Expand description

An extension of recvmsg that allows the caller to receive multiple messages from a socket using a single system call.

This has performance benefits for some applications.

This method performs no allocations.

Returns an iterator producing RecvMsg, one per received messages. Each RecvMsg can produce iterators over IoSlice with iovs and ControlMessageOwned with cmsgs.

Bugs (in underlying implementation, at least in Linux)

The timeout argument does not work as intended. The timeout is checked only after the receipt of each datagram, so that if up to vlen-1 datagrams are received before the timeout expires, but then no further datagrams are received, the call will block forever.

If an error occurs after at least one message has been received, the call succeeds, and returns the number of messages received. The error code is expected to be returned on a subsequent call to recvmmsg(). In the current implementation, however, the error code can be overwritten in the meantime by an unrelated network event on a socket, for example an incoming ICMP packet.