Exemplo n.º 1
0
        private static IPAddress[] GetIPAddressesFromDns()
        {
            IPAddress[] ipAddress = null;

            try
            {
                IPHostEntry hostInfo = Dns.GetHostEntry(ExtendedNetworkInformation.GetHostName());
                ipAddress = hostInfo.AddressList;
            }
            catch (System.Net.Sockets.SocketException)
            {
                ipAddress = new IPAddress[] { IPAddress.None };
            }

            return(ipAddress);
        }
        private async static Task <IPAddress[]> GetIPAddressesFromDnsAsync()
        {
            IPAddress[] ipAddress = null;

            try
            {
                var hostInfo = await Dns.GetHostEntryAsync(await ExtendedNetworkInformation.GetHostNameAsync());

                ipAddress = hostInfo.AddressList;
            }
            catch (System.Net.Sockets.SocketException)
            {
                ipAddress = new IPAddress[] { IPAddress.None };
            }

            return(ipAddress);
        }