浏览代码

Improve IsSocketConnected test

olegkap_cp 12 年之前
父节点
当前提交
bc4e66139b
共有 1 个文件被更改,包括 2 次插入3 次删除
  1. 2 3
      Renci.SshClient/Renci.SshNet/Session.NET.cs

+ 2 - 3
Renci.SshClient/Renci.SshNet/Session.NET.cs

@@ -24,9 +24,8 @@ namespace Renci.SshNet
 
         partial void IsSocketConnected(ref bool isConnected)
         {
-            //isConnected = (!this._isDisconnecting && this._socket != null && this._socket.Connected && this._isAuthenticated && this._messageListenerCompleted != null) && !(this._socket.Poll(10, SelectMode.SelectRead));
-            isConnected = (!this._isDisconnecting && this._socket != null && this._socket.Connected && this._isAuthenticated && this._messageListenerCompleted != null) 
-                && !(this._socket.Poll(1, SelectMode.SelectRead) && this._socket.Available == 0);
+                isConnected = (!this._isDisconnecting && this._socket != null && this._socket.Connected && this._isAuthenticated && this._messageListenerCompleted != null)
+                    && this._socket.Poll(-1, SelectMode.SelectWrite);
         }
 
         partial void SocketConnect(string host, int port)