Lesson 3.4
Connection - one socket, one message at a time
The object that owns a socket's lifecycle (feeding the parser, looping it, dispatching each message strictly in order, turning a parser error into a 400), plus the Server seam that replaces the per-chunk callback.
What you will build
- Build a Connection that pumps the parser and dispatches messages strictly sequentially.
- Explain why re-entrancy cannot corrupt the pump loop even while a dispatch is awaited.
- Land the Server seam - constructor(dispatch, options), one Connection per socket, setNoDelay first.