Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Length-delimited (framing) codec

A dnet::io::length_delimited::Codec prefixes each frame with its length in bytes.

The length prefix is used to divide the continuous byte stream into discrete frames: the codec reads the 4-byte length in big-endian order, then reads that many bytes as a single message frame.

Note

A u32 (4 bytes) is used to encode the message length in big-endian byte order. The 4 length-prefix bytes themselves are not counted in that length; the length value refers only to the subsequent message bytes.