DnsAbstraction
using Microsoft.Phone.Net.NetworkInformation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace Renci.SshNet.Abstractions
{
internal static class DnsAbstraction
{
public unsafe static IPAddress[] GetHostAddresses(string hostNameOrAddress)
{
if (IPAddress.TryParse(hostNameOrAddress, out IPAddress address))
return new IPAddress[1] {
address
};
ManualResetEvent resolveCompleted = new ManualResetEvent(false);
NameResolutionResult nameResolutionResult = null;
<>c__DisplayClass0_0 <>c__DisplayClass0_;
DeviceNetworkInformation.ResolveHostNameAsync(new DnsEndPoint(hostNameOrAddress, 0), new NameResolutionCallback((object)<>c__DisplayClass0_, (IntPtr)(void*)), (object)null);
resolveCompleted.WaitOne();
if ((int)nameResolutionResult.get_NetworkErrorCode() == 0)
return new List<IPAddress>((from p in nameResolutionResult.get_IPEndPoints()
select p.Address).Distinct()).ToArray();
throw new SocketException((int)nameResolutionResult.get_NetworkErrorCode());
}
}
}