NetCoreServer icon indicating copy to clipboard operation
NetCoreServer copied to clipboard

Is there a reason disconnect errors are not reported on TcpClient

Open h0st1le opened this issue 3 years ago • 1 comments

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);
    }

h0st1le avatar Aug 10 '20 17:08 h0st1le

https://stackoverflow.com/questions/11833808/how-to-detect-a-socket-disconnect-in-c-sharp

tharwat202020 avatar Nov 19 '20 08:11 tharwat202020