Fix IsConnected property behaviour

Fix SocketReadLine if 0 bytes received
This commit is contained in:
olegkap_cp
2012-06-06 13:11:00 +00:00
parent 3581389dd6
commit 908321c502
2 changed files with 8 additions and 4 deletions
+5 -1
View File
@@ -59,7 +59,11 @@ namespace Renci.SshNet
var data = new byte[1];
do
{
this._socket.Receive(data);
var received = this._socket.Receive(data);
// If zero bytes received then exit
if (received == 0)
break;
buffer.Add(data[0]);
}
+3 -3
View File
@@ -183,7 +183,7 @@ namespace Renci.SshNet
{
get
{
return this._socket != null && this._socket.Connected && this._isAuthenticated && this._messageListenerCompleted != null;
return (!this._isDisconnecting && this._socket != null && this._socket.Connected && this._isAuthenticated && this._messageListenerCompleted != null) && !(this._socket.Poll(10, SelectMode.SelectRead));
}
}
@@ -1844,7 +1844,7 @@ namespace Renci.SshNet
var encoding = new Renci.SshNet.Common.ASCIIEncoding();
this.SocketWrite(encoding.GetBytes(string.Format("CONNECT {0}:{1} HTTP/1.0\r\n", this.ConnectionInfo.Host, this.ConnectionInfo.Port)));
// Sent proxy authorization is specified
if (!string.IsNullOrEmpty(this.ConnectionInfo.ProxyUsername))
{
@@ -2047,4 +2047,4 @@ namespace Renci.SshNet
public Type Type { get; set; }
}
}
}
}