Message Framing
ELI5 — The Vibe Check
Message Framing is how you tell where one message ends and the next begins in a stream of bytes. TCP gives you a stream, not messages. You need framing — length prefixes, delimiters, or fixed-size headers — to chop that stream into meaningful chunks. Without it, your messages are just alphabet soup.
Real Talk
Message framing defines boundaries between discrete messages in a byte stream (TCP). Common approaches: length-prefixed (4-byte header with message size), delimiter-based (newline or null byte), and fixed-length. HTTP uses Content-Length and chunked transfer encoding. WebSocket and HTTP/2 have built-in framing.
When You'll Hear This
"We use length-prefixed framing — 4 bytes for the message size, then the message body." / "HTTP/2 frames have a 9-byte header that includes the stream ID and frame length."
Related Terms
Binary Protocol
Binary Protocols encode data as raw bytes instead of human-readable text.
Protocol Buffers
Protocol Buffers (protobuf) is Google's way of serializing data that's way smaller and faster than JSON. You define your data structure in a .
TCP (Transmission Control Protocol)
TCP is like sending a package with delivery confirmation.
WebSocket
WebSocket is like upgrading a walkie-talkie from push-to-talk to a full phone call.