Skip to content

Instantly share code, notes, and snippets.

@MrJul

MrJul/gist:5959933

Created Jul 9, 2013
Embed
What would you like to do?
Index: Renci.SshNet/Channels/ChannelDirectTcpip.cs
===================================================================
--- Renci.SshNet/Channels/ChannelDirectTcpip.cs (revision 28721)
+++ Renci.SshNet/Channels/ChannelDirectTcpip.cs (working copy)
@@ -114,11 +114,13 @@
{
exception = exp;
}
-
+
// Channel was open and we MUST receive EOF notification,
// data transfer can take longer then connection specified timeout
// If listener thread is finished then socket was closed
- System.Threading.WaitHandle.WaitAny(new WaitHandle[] { this._channelEof });
+
+ // commented out: blocks indefinitely if the remote end expects the local end to close the socket
+ //System.Threading.WaitHandle.WaitAny(new WaitHandle[] { this._channelEof });
// Close socket if still open
if (this._socket != null)
Index: Renci.SshNet/Common/Extensions.NET.cs
===================================================================
--- Renci.SshNet/Common/Extensions.NET.cs (revision 28721)
+++ Renci.SshNet/Common/Extensions.NET.cs (working copy)
@@ -28,12 +28,12 @@
internal static bool CanRead(this Socket socket)
{
- return socket.Connected && socket.Poll(-1, SelectMode.SelectRead) && socket.Available > 0;
+ return socket.Connected; // equivalent to Silverlight, maybe remove this method completely?
}
internal static bool CanWrite(this Socket socket)
{
- return socket.Connected && socket.Poll(-1, SelectMode.SelectWrite);
+ return socket.Connected; // equivalent to Silverlight, maybe remove this method completely?
}
internal static IPAddress GetIPAddress(this string host)
Index: Renci.SshNet/ForwardedPortLocal.NET.cs
===================================================================
--- Renci.SshNet/ForwardedPortLocal.NET.cs (revision 28721)
+++ Renci.SshNet/ForwardedPortLocal.NET.cs (working copy)
@@ -53,13 +53,15 @@
this.RaiseRequestReceived(originatorEndPoint.Address.ToString(), (uint)originatorEndPoint.Port);
- var channel = this.Session.CreateChannel<ChannelDirectTcpip>();
+ using (var channel = this.Session.CreateChannel<ChannelDirectTcpip>()) {
- channel.Open(this.Host, this.Port, socket);
+ channel.Open(this.Host, this.Port, socket);
- channel.Bind();
+ channel.Bind();
- channel.Close();
+ channel.Close();
+
+ }
}
catch (Exception exp)
{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment