TCP/IP Lean: Web Servers for Embedded Systems, Second Edition

Learn the "nuts and bolts" of programming for Web appliances with this in-depth guide.
Each TCP state is defined as an enumeration and as a string for diagnostic printouts.
<span style="background-color:d9d9d9">/* TCP states */</span><span style="background-color:d9d9d9">#define TSTATE_STRINGS \</span> <span style="background-color:d9d9d9">"closed", "SYN rcvd", "established", \</span> <span style="background-color:d9d9d9">"close wait", "last ACK", "reset rcvd", \</span> <span style="background-color:d9d9d9">"active open", "ARP sent", "ARP rcvd", "SYN sent", \</span> <span style="background-color:d9d9d9">"active close", "FIN wait 1", "FIN wait 2", "closing",\</span> <span style="background-color:d9d9d9">"timed wait"</span><span style="background-color:d9d9d9">typedef enum {</span> <span style="background-color:d9d9d9">/* Passive open <span class="unicode">&</span> close */</span> <span style="background-color:d9d9d9">TCP_CLOSED, /* Closed */</span> <span style="background-color:d9d9d9">TCP_SYNR, /* SYN recvd: send SYN ACK */</span> <span style="background-color:d9d9d9">TCP_EST, /* Established: connection OK */</span> <span style="background-color:d9d9d9">TCP_CLWAIT, /* Close wait: FIN recvd, send data then FIN ACK */</span> <span style="background-color:d9d9d9">TCP_LASTACK, /* Last ACK: waiting for ACK...