TCP delivers an ordered byte stream rather than preserving application write boundaries. Applications need a framing protocol.
Before you start
You should understand clients, servers, IP addresses and ports. Follow a request through name resolution, connection establishment and application exchange. Distinguish protocol guarantees from deployment policy, and use observations from the relevant layer rather than guessing from one browser error message.
The practical goal is to reason through this situation: One message can arrive across multiple reads, or multiple messages can arrive together. Read the walkthrough first, then try the interview exercise before opening its answer. The important part is explaining the decision and its consequences, rather than remembering a definition alone.
Step-by-step walkthrough
Step 1: Define frame boundaries
Application writes are not preserved as individual TCP messages.
Step 2: Parse incrementally
Keep incomplete input until enough bytes identify a full frame.
Step 3: Bound frame size
Reject malformed or oversized lengths before uncontrolled buffering.
Worked scenario
One message can arrive across multiple reads, or multiple messages can arrive together.
A sender writes HELLO and WORLD separately. The receiver can read HE, then LLOWORLD, or both messages together. A length prefix tells the parser when one frame completes; it must also handle a prefix split across reads and an incomplete body at disconnect.
Common mistake
Assuming one read equals one message breaks under ordinary network behavior.
Verify the behavior
Split and combine input at every boundary and test oversized or truncated frames.
Interview exercise
Design a small framed protocol.
Answer and reasoning
Use a length prefix or delimiter with limits and incremental parsing; handle incomplete and malformed frames.
Continue learning
Compare the scenario with the Networking interview questions and test your understanding with the Networking MCQs. For terminology and implementation details, consult the reference material.