From 14ddfca4e926c1f8a7ca1db0026434ee159f384d Mon Sep 17 00:00:00 2001 From: drieseng Date: Thu, 30 Apr 2020 13:20:49 +0200 Subject: [PATCH] Fix test failures --- .../Classes/SessionTest_ConnectedBase.cs | 1 + .../Common/AsyncSocketListener.cs | 20 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Renci.SshNet.Tests/Classes/SessionTest_ConnectedBase.cs b/src/Renci.SshNet.Tests/Classes/SessionTest_ConnectedBase.cs index 074ab059..3e42dac1 100644 --- a/src/Renci.SshNet.Tests/Classes/SessionTest_ConnectedBase.cs +++ b/src/Renci.SshNet.Tests/Classes/SessionTest_ConnectedBase.cs @@ -97,6 +97,7 @@ namespace Renci.SshNet.Tests.Classes }; ServerListener = new AsyncSocketListener(_serverEndPoint); + ServerListener.ShutdownRemoteCommunicationSocket = false; ServerListener.Connected += socket => { ServerSocket = socket; diff --git a/src/Renci.SshNet.Tests/Common/AsyncSocketListener.cs b/src/Renci.SshNet.Tests/Common/AsyncSocketListener.cs index d446408e..dbb6128b 100644 --- a/src/Renci.SshNet.Tests/Common/AsyncSocketListener.cs +++ b/src/Renci.SshNet.Tests/Common/AsyncSocketListener.cs @@ -27,8 +27,20 @@ namespace Renci.SshNet.Tests.Common { _endPoint = endPoint; _acceptCallbackDone = new ManualResetEvent(false); + ShutdownRemoteCommunicationSocket = true; } + /// + /// Gets a value indicating whether the is invoked on the + /// that is used to handle the communication with the remote host, when the remote host has closed the connection. + /// + /// + /// to invoke on the that is used + /// to handle the communication with the remote host, when the remote host has closed the connection; otherwise, + /// . The default is . + /// + public bool ShutdownRemoteCommunicationSocket { get; set; } + public void Start() { _listener = new Socket(_endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); @@ -127,8 +139,12 @@ namespace Renci.SshNet.Tests.Common else { SignalDisconnected(handler); - handler.Shutdown(SocketShutdown.Both); - handler.Close(); + + if (ShutdownRemoteCommunicationSocket) + { + handler.Shutdown(SocketShutdown.Both); + handler.Close(); + } } }