Skip to main content

sendmmsg_with_suffix

Function sendmmsg_with_suffix 

Source
pub fn sendmmsg_with_suffix(
    fd: BorrowedFd<'_>,
    bufs: &[ReadBuf<'_>],
    suffix: &[u8],
) -> Result<usize>
Expand description

Sends multiple datagrams, appending the same suffix to every datagram.

This is useful for situations where the datagrams carry UDP payloads, which can create an ambiguous situation: an empty UDP payload is valid in a UDP IP packet, but reading 0 bytes from a datagram socket is also a signal of a closed socket. So the suffix can add a marker to every payload to tell those cases apart, and this allows to send that efficiently.

The returned value is the number of datagrams sent. The suffix is framing supplied on the caller’s behalf and does not affect that count.