Dns.GetHostEntry(String value) : Dns « System.Net « C# / C Sharp by API






Dns.GetHostEntry(String value)

  

using System;
using System.Net;

class MainClass
{
    public static void Main(string[] args) 
    {
        foreach (string comp in args) 
        {
            try
            {
                IPAddress[] addresses = Dns.GetHostEntry(comp).AddressList;

                foreach (IPAddress address in addresses)
                {
                    Console.WriteLine("{0} = {1} ({2})", 
                        comp, address, address.AddressFamily);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0} = Error ({1})", comp, ex.Message);
            }
        }
    }
}

   
    
  








Related examples in the same category

1.Dns.EndResolve(IAsyncResult ar)
2.Dns.GetHostByAddress(IPAddress ip)
3.Dns.GetHostByName
4.Dns.GetHostName()
5.Dns.Resolve