2
I've started using sockets in programming with Java (I have experience with Python), and while testing a server that I'd written with the telnet
command, I noticed that the utility responds immediately to the server being killed. When I write a client with Java (or Python), it takes at the very least a few seconds for the program indicate that it has been disconnected. As far as I know, there isn't a way to test if a socket is connected, short of a heartbeat message, which my server was not written to accept or receive.
My question is, how to the folks at GNU know when my socket has been disconnected? Is there a part of TCP that I failed to find in my searching that would allow this? Thanks.
Btw, if the session is not closed properly and the other end "goes away", then it will be cleared from the session table at some future time - this varies from OS to OS. – Paul – 2011-11-06T01:55:41.847
I don't see how that accounts for the difference in the time it takes for the telnet utility to notice it vs my utility. Is it a difference in the socket libraries that they are using? – Michael Smith – 2011-11-06T15:53:36.603
It is impossible to account for the differences without knowing more about what your utility does in response to the traffic it sees - which is why I suggested wireshark. If you see the fin-ack sequence come in, and yet your utility still has the socket defined as open, it is either a bug in the underlying library or the utility itself. – Paul – 2011-11-06T20:51:46.753