TCP ESTABLISHED status even after network cable unplugged
posted 4 years ago
Note: I posted this on a Windows 7 forum and have not gotten much response. I realize this may not be a Java issue but I'm hoping someone may understand my problem and know what to do about it.
I have a Java application that establishes a socket connection w/ another application on a different machine. When this connection is disrupted (e.g., pull out network cable), I recognize this condition and take some action.
The application creates a Socket object, sets keep alive to true an then calls ObjectInputStream.readUnshared(). This call "hangs" until the server returns something or it times out. In the case when the network connection is disrupted and the call returns as a result...
In a Windows XP 32-bit environment, this happens quickly ... in seconds.
In a Windows 7 64-bit environment, this happens slowly ... in about 5 minutes.
If I run netstat in the Windows 7 environment, the TCP connection shows ESTABLISHED for about 5 minutes after the network cable has been unplugged. (In WXP, it changes in seconds.)
I've googled, searched both the Microsoft and this forum and have heard a few people refer to 5 minutes as being a "default" timeout value. I've also looked at the TCP spec, etc. to learn a bit more, understand it better, etc. in an attempt to find something I can configure to reduce the 5 minutes to seconds but I've not run into anything that works. I found documentation for a registry entry named TcpTimedWaitDelay for the TCP/IP service. It describes the default to be 240 seconds (4 minutes) and suggests it be set to 30. In the W7 environment, this entry was not set so I added it and restarted the machine. This did not work.