WS 2008 R2: network cable unplugged but connection not closed as it should be (winsock recv() function hangs on...) RRS feed

  • Question

  • Hello,

    We just migrate to a new HP Proliant ML370 G6 running with Windows 2008 R2, and we've got a network issue.

    I built using Visual Studio 2008 a Windows application (in C/C++) that communicates with a SIEMENS PLC through TCP. This communication is operational and working, data are exchanged properly.

    We wanted to test the ability of our Application to renew its connection with the PLC with a network issue occus. We chose to make a simple test: unplug the network cable. This simple test is always working with teh same application when it runs under Windows XP, Windown Server 2000, Winodws Server 2003, Windows Server 2003 R2 and Windows Server 2008. But with Windows Server 2008 R2, it does NOT work.

    I've checked in debug mode of my application that when the network cable is unplugged, the winsock recv() function does not return anything and seems to "wait", while running with other windows operating systems, the normal behaviour is to get a value 0 when the connection has been gracefully closed, otherwise, a value of SOCKET_ERROR is returned.

    In our case, no error, and none 0 value, meaning the connection is not gracefully closed. Of course, in the network center the connection has disappeared meaning it is disconnected.


    Final words: if I click disable the network card when the cable is plugged, then my application detects the connection is closed and the reconnection process within it restarts (close old socket, create new socket and try to connect) until I unable the network card again. Then the connection is established again and it works as before. But just dissconnecting the network cable does not behave the same way.

    I'd like to understand this behaviour which is unproper to our application and find a solution how to fix this.


    Thanks in advance for your help,


    Saturday, October 2, 2010 7:55 PM

All replies

  • Hello Thierrite,

    I was wandering if you found the resolution for the issue you had a year ago with connections that were not closed in Windows 2008 R2. 

    I'm having the same issue on virtual machine running a Windows 2008 R2 and I am looking for information and resolution of this topic.

    Any information that you found will help.

    Thank you


    Friday, December 2, 2011 8:04 PM