Skip to main content

write_message

Function write_message 

Source
fn write_message(
    stream: &mut UnixStream,
    kind: u8,
    body: &[u8],
) -> Result<(), String>
Expand description

Write one message: its length, its kind, then the body.

The whole message is bounded, not just one syscall. The stream’s own write timeout bounds each write; a peer that drains a byte at a time would still hold the message for hours, so the deadline is checked with it and the message is abandoned whole - the next one carries the page.