From 210f522b29f20f5ea51a99808960d372be3253ef Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Wed, 29 Mar 2017 12:32:20 +0300 Subject: [PATCH] Minor logging improvement --- SMBLibrary/Server/SMBServer.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/SMBLibrary/Server/SMBServer.cs b/SMBLibrary/Server/SMBServer.cs index 93f85c4..0e8cfef 100644 --- a/SMBLibrary/Server/SMBServer.cs +++ b/SMBLibrary/Server/SMBServer.cs @@ -160,19 +160,28 @@ namespace SMBLibrary.Server } catch (ObjectDisposedException) { + state.LogToServer(Severity.Debug, "The connection was terminated"); m_connectionManager.ReleaseConnection(state); return; } - catch (SocketException) + catch (SocketException ex) { + const int WSAECONNRESET = 10054; + if (ex.ErrorCode == WSAECONNRESET) + { + state.LogToServer(Severity.Debug, "The connection was forcibly closed by the remote host"); + } + else + { + state.LogToServer(Severity.Debug, "The connection was terminated, Socket error code: {0}", ex.ErrorCode); + } m_connectionManager.ReleaseConnection(state); return; } if (numberOfBytesReceived == 0) { - // The other side has closed the connection - state.LogToServer(Severity.Debug, "The other side closed the connection"); + state.LogToServer(Severity.Debug, "The client closed the connection"); m_connectionManager.ReleaseConnection(state); return; }