12th July 2015 by aegeuana_sjp_admin
TCP Socket States
Sockets are a way of opening a full duplex communication between two end points, in order to open the communication certain negotiation is required between the both parties, this negotiation is done by
sending a special crafted packet with to indicate the different states. The Socket states indicate the current state in which the socket is in, this tutorial assume a basic knowledge of *BSD sockets.
There are several socket states.
Indicates that the socket is in listening mode and is ready to accept a new connection.
The client sent the syncronous request and is waiting for a response from the server.
At this stage both ends are ready to send data, the data can flow both ways (full duplex).
The remote host wants to close the connection, the client will will be in this state.
This is similar to FIN_WAIT_1 but is sort of grace
The client wants to close the connection
This state indicates that the connection is being dropped and is waiting for the acknolegment from the server
This state is the default state when no new connection is established, each connection will start with this state. This also means the connection is completelyt closed and acknoledged
Here is an example of a full TCP socket transition from CLOSED->ESTABLISHED->DATA TRANSFER->CLOSED
Header file of default states: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/net/tcp_states.h?id=HEAD#n16
Description of TCP states: http://www.cs.northwestern.edu/~kch670/eecs340/proj2-TCP_IP_State_Transition_Diagram.pdf
TCP man page: https://www.freebsd.org/cgi/man.cgi?query=tcp&apropos=0&sektion=4&manpath=FreeBSD+11-current&arch=default&format=html