I am having a small server (TCP server) which accepts at the max 10 connections on port 5000. I have created a socket in listen mode and accept connections. When accept succeeds, I create a new thread and handle traffic in that thread. I have a client on the same machine which is able to connect and communicate with this server.
Now to understand TIME_WAIT, I kill my server application using ctrl+c. I expect to see the server sockets which were in "Established" state to be transferred to "TIME_WAIT". However, when I do netstat after the closure, I dont see a single socket in that "TIME_WAIT" state. I know that sockets in "listen" mode directly transition to CLOSED state. But I am confused why sockets returned by accept and currently in Established state are not in TIME_WAIT state.
(I am on a linux machine and tcp_fin_timeout value is set to 1min.)
My tcpdump looks like below:
localhost.49388 > localhost.5000:
Flags [S], cksum 0xfe30 (incorrect -> 0xaa93), seq 3264533269, win 32792,
options [mss 16396,sackOK,TS val 20216234 ecr 0,nop,wscale 3], length 0
localhost.5000 > localhost.49388:
Flags [S.], cksum 0xfe30 (incorrect -> 0xc6a0), seq 3352338762, ack 3264533270, win 32768,
options [mss 16396,sackOK,TS val 20216234 ecr 20216234,nop,wscale 3], length 0
localhost.49388 > localhost.5000:
Flags [.], cksum 0xfe28 (incorrect -> 0x9fbe), ack 1, win 4099,
options [nop,nop,TS val 20216234 ecr 20216234], length 0
localhost.5000 > localhost.49388:
Flags [P.], cksum 0xfe42 (incorrect -> 0xa300), seq 1:27, ack 1, win 4096,
options [nop,nop,TS val 20216484 ecr 20216234], length 26
localhost.49388 > localhost.5000:
Flags [.], cksum 0xfe28 (incorrect -> 0x9db0), ack 27, win 4099,
options [nop,nop,TS val 20216484 ecr 20216484], length 0
localhost.49388 > localhost.5000:
Flags [P.], cksum 0x0211 (incorrect -> 0x6be1), seq 1:1001, ack 27, win 4099,
options [nop,nop,TS val 20216484 ecr 20216484], length 1000
localhost.5000 > localhost.49388:
Flags [.], cksum 0xfe28 (incorrect -> 0x91cb), ack 1001, win 6144,
options [nop,nop,TS val 20216484 ecr 20216484], length 0
localhost.5000 > localhost.49388:
Flags [R.], cksum 0xfe28 (incorrect -> 0x8eeb), seq 27, ack 1001, win 6144,
options [nop,nop,TS val 20217216 ecr 20216484], length 0