diff --git a/src/Renci.SshNet/Channels/ChannelDirectTcpip.cs b/src/Renci.SshNet/Channels/ChannelDirectTcpip.cs index 9ae5d6766..5be28205a 100644 --- a/src/Renci.SshNet/Channels/ChannelDirectTcpip.cs +++ b/src/Renci.SshNet/Channels/ChannelDirectTcpip.cs @@ -132,7 +132,21 @@ private void ShutdownSocket(SocketShutdown how) if (_socket == null || !_socket.Connected) return; - _socket.Shutdown(how); + try + { + _socket.Shutdown(how); + } + catch (SocketException ex) + { + if (ex != null && ex.Message != null && ex.Message.Contains("The socket is not connected")) + { + DiagnosticAbstraction.Log("Eating a 'socket is not connected' message, because we're closing this socket anyway."); + } + else + { + throw; + } + } } }