From 801c9e57c0a614e8ace3336a5c9a02258fe00b10 Mon Sep 17 00:00:00 2001 From: Cristian Pop Date: Tue, 28 Jun 2016 14:07:54 -0700 Subject: [PATCH] Routing all BeginConnect calls through UnsafeBeginConnect to allow connectionless protocols to bind to the remote endpoint. Commit migrated from https://github.com/dotnet/corefx/commit/c4181be8695d88e3fd39ddcdf75d8a0dfd97abf0 --- src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs | 8 ++++---- .../System.Net.Sockets/tests/FunctionalTests/UdpClientTest.cs | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs index 062c1cd..1adf9ec 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs @@ -2293,7 +2293,7 @@ namespace System.Net.Sockets return BeginConnect(dnsEP.Host, dnsEP.Port, callback, state); } - return BeginConnectEx(remoteEP, true, callback, state); + return UnsafeBeginConnect(remoteEP, callback, state, flowContext:true); } private bool CanUseConnectEx(EndPoint remoteEP) @@ -2302,11 +2302,11 @@ namespace System.Net.Sockets (_rightEndPoint != null || remoteEP.GetType() == typeof(IPEndPoint)); } - internal IAsyncResult UnsafeBeginConnect(IPEndPoint remoteEP, AsyncCallback callback, object state) + internal IAsyncResult UnsafeBeginConnect(EndPoint remoteEP, AsyncCallback callback, object state, bool flowContext = false) { if (CanUseConnectEx(remoteEP)) { - return BeginConnectEx(remoteEP, false, callback, state); + return BeginConnectEx(remoteEP, flowContext, callback, state); } EndPoint endPointSnapshot = remoteEP; @@ -5913,7 +5913,7 @@ namespace System.Net.Sockets connectSocket = context._lastAttemptSocket; } - IAsyncResult connectResult = connectSocket.UnsafeBeginConnect((IPEndPoint)endPoint, CachedMultipleAddressConnectCallback, context); + IAsyncResult connectResult = connectSocket.UnsafeBeginConnect(endPoint, CachedMultipleAddressConnectCallback, context); if (connectResult.CompletedSynchronously) { return connectResult; diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/UdpClientTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/UdpClientTest.cs index f2f4cdb..5f5ae3e 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/UdpClientTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/UdpClientTest.cs @@ -76,7 +76,6 @@ namespace System.Net.Sockets.Tests } [Fact] - [ActiveIssue(9304)] public async Task ConnectAsync_IPAddressHost_Success() { using (var c = new UdpClient()) -- 2.7.4