SYN Queue and Accept Queue
0x00 A Single Queue or Two Queues
TCP/IP stack has two options to implement the backlog queue for a socket in the LISTEN
state.
Door #1: A Single Queue
A single queue can contain connections in two different states:
- SYN RECEIVED
- ESTABLISHED
And only connections in ESTABLISHED
state can be returned to the application by calling the accept()
syscall.
Therefore, the length of this queue is determined by the backlog
argument of the listen()
syscall.
Door #2: A SYN Queue & An Accept Queue
In this case, connections in state SYN RECEIVED
are added to the SYN queue, and later moved to the accept queue when their state changes to ESTABLISHED
.