Message framing
Also called: message boundaries, length-prefix framing
Message framing tells a receiver where one message ends and the next begins. Common approaches include a length prefix, a delimiter with escaping rules, or a fixed message size. Framing matters when the underlying service delivers a stream of bytes without preserving the application’s write boundaries.
For DNS over TCP, a two-byte length precedes each DNS message and excludes those two bytes from the length. A receiver may need several reads to collect one message, or may receive pieces of several messages together. Correct framing reconstructs messages independently of how network reads happen to split the bytes.
- Read first
- Protocol
- Related
- Serialization, TCP, DNS