NetCoreServer
NetCoreServer copied to clipboard
Is there a reason disconnect errors are not reported on TcpClient
I recently started using the HttpClient but noticed that whenever the server was not available or connection was refused no error is reported back. I went digging and noticed that for some reason TcpClient ignores these type of SocketErrors. Is there a reason for this? I would think it would be better to pass these errors up the chain to be handled by the inherited client.
from TcpClient
private void SendError(SocketError error)
{
// Skip disconnect errors
if ((error == SocketError.ConnectionAborted) ||
(error == SocketError.ConnectionRefused) ||
(error == SocketError.ConnectionReset) ||
(error == SocketError.OperationAborted) ||
(error == SocketError.Shutdown))
return;
OnError(error);
}
https://stackoverflow.com/questions/11833808/how-to-detect-a-socket-disconnect-in-c-sharp