Sfoglia il codice sorgente

Throw an exception if connection could not be established

olegkap_cp 13 anni fa
parent
commit
67c90147df
1 ha cambiato i file con 4 aggiunte e 1 eliminazioni
  1. 4 1
      Renci.SshClient/Renci.SshNet/Session.NET.cs

+ 4 - 1
Renci.SshClient/Renci.SshNet/Session.NET.cs

@@ -42,7 +42,10 @@ namespace Renci.SshNet
             //  Connect socket with specified timeout
             var connectResult = this._socket.BeginConnect(ep, null, null);
 
-            connectResult.AsyncWaitHandle.WaitOne(this.ConnectionInfo.Timeout, false);
+            if (!connectResult.AsyncWaitHandle.WaitOne(this.ConnectionInfo.Timeout, false))
+            {
+                throw new SshOperationTimeoutException("Connection Could Not Be Established");
+            }
 
             this._socket.EndConnect(connectResult);
         }