-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISSUE#416 Fixed Socket.ConnectAsync timeout issue (#466)
Co-authored-by: Yurii Pelekh <[email protected]> Co-authored-by: Gutemberg Ribeiro <[email protected]>
- Loading branch information
1 parent
5bc8c3e
commit c0f44a7
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/Docker.DotNet/Microsoft.Net.Http.Client/SocketExtensionMethods.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Net; | ||
using System.Net.Sockets; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.Net.Http.Client | ||
{ | ||
public static class SocketExtensionMethods | ||
{ | ||
public static async Task ConnectAsync(this Socket socket, IPAddress address, int port, CancellationToken cancellationToken) | ||
{ | ||
Task socketConnectTask = socket.ConnectAsync(address, port); | ||
Task delayTask = Task.Delay(int.MaxValue, cancellationToken); | ||
|
||
await await Task.WhenAny(socketConnectTask, delayTask); | ||
} | ||
} | ||
} |