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.

35 minsrc/connection.js, src/server.js, examples/hello.js
  • 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.
Locked

This chapter is part of the framework capstone. Chapters 1 and 2 are free to build - unlock the rest to keep going.

Unlock the depth