I have a socket connection between a client process and a server process, both running on my machine. There are two entries shown for the connection as,
sudo netstat -ntp | grep 56442
tcp 1 0 127.0.0.1:56442 127.0.0.1:8002 CLOSE_WAIT 8276/python
tcp 0 0 127.0.0.1:8002 127.0.0.1:56442 FIN_WAIT2 -
How can I figure out which is the server in this case?
I know that the TCP server is running on port 8002
, and a client connects to the listening server from port 56442
.
I am trying to figure out a way to distinguish between server and client, by looking at the netstat
output entries.
And why doesn't the process id/description appear when the socket is in FIN_WAIT2
state?
netstat -ntp
you will see that the first line tells you what each column represents. "Local Address" will be the address and portlisten()
ing (i.e the server bound on port 8002).FIN-WAIT-1
andFIN-WAIT-2
states; that can be either the client or the server side.