Quote:
Originally Posted by bill_nimmo
Hello All,
I realize this topic has been addressed before. From what I have read, a socket 'recv' on the server side returns 0 when the client has closed the connection. I am experiencing this situation in cases where it probably shouldnt happen.
|
While I may have roughly the same level of networking skills as you, may I suggest tracing? On the server, run
Code:
tcpdump -i <network interface> port <whatever port you use>
Output can be written to a file using the -w option and then analyzed later, using the -r option. Or use wireshark if you have a GUI on the server. You would have to look for a packet with the FIN bit set in the header.
Here are my notes about establishing and closing a connection, summarized from
http://tangentsoft.net/wskfaq/articl...ging-tcp.html:
Code:
Client Server
CLOSED CLOSED
connect() listen()
send SYN LISTEN
SYN_SENT
send SYN; ACK
SYN_RCVD
send ACK
ESTABLISHED
send nothing
ESTABLISHED
------------- data transfer ------------
close()
send FIN
FIN_WAIT_1
send ACK
CLOSE_WAIT
send nothing
FIN_WAIT_2
close()
send FIN
LAST_ACK
send ACK
TIME_WAIT
send nothing
CLOSED
<timeout>
CLOSED
where CLOSED, TIME_WAIT, FIN_WAIT and so on are socket states which you can see with
netstat.