Hi,
I'm having an issue with the Socket.SendAsync method not detecting a dead TCP connection. In my client/server app, the server is sending heartbeats to connected clients in regular intervals.
The issue that I'm experiencing is that even though the client might be dead, the callbacks from the SendAsync method indicate "SocketError.Success" and the Socket.Connected property is true, even though the client is no longer "alive". So, to the server it looks like the heartbeat data was sent properly and the client is still alive.
I'm seeing this issue every time, the client side PC is either put to sleep/hibernate or e.g. when the client is running in a VMWare instance and that instance becomes suspended. I do not see this issue when the client shuts down the application, kills it from the taskmanager, etc.
internal void InternalSendAsync(ByteDataChunk chunk)
{
asyncSendArgs.SetBuffer(chunk.Buffer, 0, chunk.Offset);
asyncSendArgs.UserToken = chunk;
Socket.SendAsync(asyncSendArgs);
}
private void SendCompleted(object sender, SocketAsyncEventArgs args)
{
if (args.SocketError != SocketError.Success || !Socket.Connected)
{
InternalDisconnect(args.SocketError);
return;
}
// all is good & do some other stuff
}
Anybody has any idea what's going on here and why the SendCompleted method does not return a SocketError even though the client is long dead (I've had the server run for multiple hours before and the dead socket was never detected)?
Thanks,
Tom