These were written as sync-over-async before the sync APIs were available. Now that the sync APIs are available, use them.
Commit migrated from https://github.com/dotnet/corefx/commit/
5cb6b8b340aafc3d7c6afe212fab103ef697fa02
IPEndPoint ipEndPoint = null;
if (hostname != null && port != 0)
{
- IPAddress[] addresses = Dns.GetHostAddressesAsync(hostname).GetAwaiter().GetResult();
+ IPAddress[] addresses = Dns.GetHostAddresses(hostname);
int i = 0;
for (; i < addresses.Length && !IsAddressFamilyCompatible(addresses[i].AddressFamily); i++)
// Perf note: The .NET Framework caches this and then uses network change notifications to track
// whether the set should be recomputed. We could consider doing the same if this is observed as
// a bottleneck, but that tracking has its own costs.
- IPAddress[] localAddresses = Dns.GetHostEntryAsync(Dns.GetHostName()).GetAwaiter().GetResult().AddressList; // TODO: Use synchronous GetHostEntry when available
+ IPAddress[] localAddresses = Dns.GetHostEntry(Dns.GetHostName()).AddressList;
for (int i = 0; i < localAddresses.Length; i++)
{
if (ipAddress.Equals(localAddresses[i]))