Skip to content

Commit 14ddfca

Browse files
committed
Fix test failures
1 parent 916c019 commit 14ddfca

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/Renci.SshNet.Tests/Classes/SessionTest_ConnectedBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ protected virtual void SetupData()
9797
};
9898

9999
ServerListener = new AsyncSocketListener(_serverEndPoint);
100+
ServerListener.ShutdownRemoteCommunicationSocket = false;
100101
ServerListener.Connected += socket =>
101102
{
102103
ServerSocket = socket;

src/Renci.SshNet.Tests/Common/AsyncSocketListener.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,20 @@ public AsyncSocketListener(IPEndPoint endPoint)
2727
{
2828
_endPoint = endPoint;
2929
_acceptCallbackDone = new ManualResetEvent(false);
30+
ShutdownRemoteCommunicationSocket = true;
3031
}
3132

33+
/// <summary>
34+
/// Gets a value indicating whether the <see cref="Socket.Shutdown(SocketShutdown)"/> is invoked on the <see cref="Socket"/>
35+
/// that is used to handle the communication with the remote host, when the remote host has closed the connection.
36+
/// </summary>
37+
/// <value>
38+
/// <see langword="true"/> to invoke <see cref="Socket.Shutdown(SocketShutdown)"/> on the <see cref="Socket"/> that is used
39+
/// to handle the communication with the remote host, when the remote host has closed the connection; otherwise,
40+
/// <see langword="false""/>. The default is <see langword="true"/>.
41+
/// </value>
42+
public bool ShutdownRemoteCommunicationSocket { get; set; }
43+
3244
public void Start()
3345
{
3446
_listener = new Socket(_endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
@@ -127,8 +139,12 @@ private void ReadCallback(IAsyncResult ar)
127139
else
128140
{
129141
SignalDisconnected(handler);
130-
handler.Shutdown(SocketShutdown.Both);
131-
handler.Close();
142+
143+
if (ShutdownRemoteCommunicationSocket)
144+
{
145+
handler.Shutdown(SocketShutdown.Both);
146+
handler.Close();
147+
}
132148
}
133149
}
134150

0 commit comments

Comments
 (0)