Skip to content

Commit 563349d

Browse files
committed
When the port is closing, first shutdown the send part of the socket.
Subsequently close/dispose the socket to ensure the blocking receive is interrupted.
1 parent 1e63a81 commit 563349d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Renci.SshNet/Channels/ChannelDirectTcpip.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ public void Open(string remoteHost, uint port, IForwardedPort forwardedPort, Soc
6868
/// </summary>
6969
private void ForwardedPort_Closing(object sender, EventArgs eventArgs)
7070
{
71-
// signal to the client that we will not send anything anymore; this will also interrupt the
71+
// signal to the client that we will not send anything anymore; this should also interrupt the
7272
// blocking receive in Bind if the client sends FIN/ACK in time
73-
//
74-
// if the FIN/ACK is not sent in time, the socket will be closed in Close(bool)
7573
ShutdownSocket(SocketShutdown.Send);
74+
75+
// if the FIN/ACK is not sent in time by the remote client, then interrupt the blocking receive
76+
// by closing the socket
77+
CloseSocket();
7678
}
7779

7880
/// <summary>

0 commit comments

Comments
 (0)