Raw TCP/IP socket communication
summary
Crash course in building reliable always-on TCP/IP device protocols: TCP gives a byte stream not packets, writes complete when bytes hit the local OS, reads can be partial and a socket’s “connected” flag is meaningless. Design around three pillars: length-prefix framing (or delimiters with escaping), explicit periodic ping on both sides for half-open detection (stack keep-alives are unreliable and often 2h), and always be reading while using async I/O. Write a formal spec, version it, log every byte, test with Wireshark/Clumsy.
AI-written summary · about
