Team LiB
Previous Section Next Section

DNS Name Resolution

To handle Domain Name System (DNS) name resolution, use the Dns class Resolve method. The following example demonstrates how to implement this.

Code Example: DNS Name Resolution
Start example
using System;
using System.Net;


namespace Client.Chapter_14___Networking_and_WWW_Connections
{
          class Class1
          {
                [STAThread]
                static void Main(string[] args)
                {
                       IPHostEntry MyHost = Dns.Resolve(args[0]);
                       foreach (IPAddress MyIP in MyHost.AddressList)
                       {
                                Console.WriteLine(MyIP.Address);
                       }
                }
          }
}
End example

Team LiB
Previous Section Next Section