📖 Book · sockets · high
🌐 TCP is a stream: framing & byte order
Why send≠recv, how to length-prefix your messages, and host vs network byte order.
The #1 socket gotcha: TCP is a boundary-less byte stream, so you must frame messages yourself. A runnable length-prefix encoder with htonl/ntohl byte-order conversion, the send_all/recv_all loops for partial transfers, and EINTR / recv()==0 / TCP_NODELAY.
3 chapters▶ runnable code✦ in-depth animation
What this book covers
- 01TCP is a byte stream, not messages
- 02Framing + byte order — run it
- 03The I/O loops & partial transfers
Read it in full — runnable C++ + step-through animations
Every chapter of TCP is a stream: framing & byte order ships complete, editable code you compile and run in the browser, plus the same in-depth animations as the lessons.