Throw an exception if connection could not be established

This commit is contained in:
olegkap_cp
2012-12-19 20:51:15 +00:00
parent d0241f5853
commit 67c90147df
+4 -1
View File
@@ -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);
}