Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit ecbece3

Browse files
authored
Always use DnsEndPoint in SocketHttpHandler's ConnectAsync (#29286) (#29303)
We had a minor optimization here, but there's a long-standing issue with Socket.ConnectAsync where it's leaving for finalization a socket when the connect with an IP address fails. It's more important to address that issue, and using DnsEndPoint does so (it's also the code we want, anyway).
1 parent 3fb2e82 commit ecbece3

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ public CertificateCallbackMapper(Func<HttpRequestMessage, X509Certificate2, X509
5454
saea.Initialize(cancellationToken);
5555

5656
// Configure which server to which to connect.
57-
saea.RemoteEndPoint = IPAddress.TryParse(host, out IPAddress address) ?
58-
(EndPoint)new IPEndPoint(address, port) :
59-
new DnsEndPoint(host, port);
57+
saea.RemoteEndPoint = new DnsEndPoint(host, port);
6058

6159
// Initiate the connection.
6260
if (Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, saea))

0 commit comments

Comments
 (0)