Socket hanging on CLOSE_WAIT
Hi Gurus,
I have a C# project on VS2008, Framework 3.5.
I'm using a TCP socket like that:
Socket mClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
mClientSocket.NoDelay = true;
mClientSocket.Blocking = true;
mClientSocket.DontFragment = false;
mClientSocket.LingerState.Enabled = false;
mClientSocket.LingerState.LingerTime = 0;
mClientSocket.UseOnlyOverlappedIO = true;
// Get the remote IP address.
System.Net.IPAddress[] IPs = System.Net.Dns.GetHostAddresses(ExchangeIPAddress); // ExchangeIPAddress is a string with the IP address
IPAddress ip = IPs[0];
int iPortNo = System.Convert.ToInt32(ExchangePort);// ExchangePort is string with the port
// Create the end point.
IPEndPoint ipEnd = new IPEndPoint(ip, iPortNo);
// Connect to the remote host.
mClientSocket.Connect(ipEnd);
I have some cases that the socket is hanging on CLOSE_WAIT (shown on the Process Explorer), and stay like that forever, causing the data flow to cease.
There is no error return value anywhere, and no exception is thrown.
Therefore; I have no idea to what can cause this. Only closing the client application and starting it again, solve the problem. I this client restart is not acceptable solution.
Can anyone aid me to find what might cause this CLOSE_WAIT to hang like that?
--
Thanks
Sharon