From 67c90147df2d8672b565cddbbe60fb3c2519a8bd Mon Sep 17 00:00:00 2001 From: olegkap_cp Date: Wed, 19 Dec 2012 20:51:15 +0000 Subject: [PATCH] Throw an exception if connection could not be established --- Renci.SshClient/Renci.SshNet/Session.NET.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Renci.SshClient/Renci.SshNet/Session.NET.cs b/Renci.SshClient/Renci.SshNet/Session.NET.cs index a18b50a3..fb95f21d 100644 --- a/Renci.SshClient/Renci.SshNet/Session.NET.cs +++ b/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); }