File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -95,14 +95,19 @@ public async Task ConnectAsync()
95
95
bool success = false ;
96
96
97
97
var connTask = _socket . ConnectAsync ( _endpoint ) ;
98
+
98
99
if ( await Task . WhenAny ( connTask , Task . Delay ( _connectionTimeout ) ) == connTask )
99
100
{
100
101
await connTask ;
101
102
}
102
- else if ( _socket != null )
103
+ else
103
104
{
104
- _socket . Dispose ( ) ;
105
- _socket = null ;
105
+ if ( _socket != null )
106
+ {
107
+ _socket . Dispose ( ) ;
108
+ _socket = null ;
109
+ }
110
+ throw new TimeoutException ( $ "Timeout to connect to { _endpoint } .") ;
106
111
}
107
112
108
113
if ( _socket != null )
@@ -424,21 +429,21 @@ public async Task WriteAsync(IList<ArraySegment<byte>> buffers)
424
429
#region [ License information ]
425
430
426
431
/* ************************************************************
427
- *
432
+ *
428
433
* Copyright (c) 2010 Attila Kisk? enyim.com
429
- *
434
+ *
430
435
* Licensed under the Apache License, Version 2.0 (the "License");
431
436
* you may not use this file except in compliance with the License.
432
437
* You may obtain a copy of the License at
433
- *
438
+ *
434
439
* http://www.apache.org/licenses/LICENSE-2.0
435
- *
440
+ *
436
441
* Unless required by applicable law or agreed to in writing, software
437
442
* distributed under the License is distributed on an "AS IS" BASIS,
438
443
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
439
444
* See the License for the specific language governing permissions and
440
445
* limitations under the License.
441
- *
446
+ *
442
447
* ************************************************************/
443
448
444
449
#endregion
You can’t perform that action at this time.
0 commit comments