1 parent 6501df3 commit 4eab1dfCopy full SHA for 4eab1df
1 file changed
StartSch/HappyEyeballs.cs
@@ -21,8 +21,20 @@ public static async ValueTask<Stream> SocketsHttpHandlerConnectCallback(
21
SocketsHttpConnectionContext ctx,
22
CancellationToken ct)
23
{
24
- if (IPAddress.TryParse(ctx.DnsEndPoint.Host, out IPAddress? _))
25
- throw new NotImplementedException();
+ if (IPAddress.TryParse(ctx.DnsEndPoint.Host, out IPAddress? ipAddress))
+ {
26
+ Socket ipSocket = new(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp) { NoDelay = true };
27
+ try
28
29
+ await ipSocket.ConnectAsync(ipAddress, ctx.DnsEndPoint.Port, ct);
30
+ return new NetworkStream(ipSocket, true);
31
+ }
32
+ catch
33
34
+ ipSocket.Dispose();
35
+ throw;
36
37
38
39
DnsEndPoint dnsEndPoint = ctx.DnsEndPoint;
40
0 commit comments