Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Simplified ProcessResult code
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffCyr committed Feb 9, 2018
1 parent 795e5be commit a9a3403
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -460,23 +460,19 @@ private static unsafe void ProcessResult(SocketError errorCode, GetAddrInfoExCon
if (canonicalName == null && result->ai_canonname != IntPtr.Zero)
canonicalName = Marshal.PtrToStringUni(result->ai_canonname);

IPAddress ipAddress = null;
var socketAddress = new ReadOnlySpan<byte>(result->ai_addr, result->ai_addrlen);

if (result->ai_family == AddressFamily.InterNetwork)
{
if (socketAddress.Length == SocketAddressPal.IPv4AddressSize)
ipAddress = CreateIPv4Address(socketAddress);
addresses.Add(CreateIPv4Address(socketAddress));
}
else if (SocketProtocolSupportPal.OSSupportsIPv6 && result->ai_family == AddressFamily.InterNetworkV6)
{
if (socketAddress.Length == SocketAddressPal.IPv6AddressSize)
ipAddress = CreateIPv6Address(socketAddress);
addresses.Add(CreateIPv6Address(socketAddress));
}

if (ipAddress != null)
addresses.Add(ipAddress);

result = result->ai_next;
}

Expand Down

0 comments on commit a9a3403

Please sign in to comment.