Dns.EndResolve(IAsyncResult ar) : Dns « System.Net « C# / C Sharp by API






Dns.EndResolve(IAsyncResult ar)

  

using System;
using System.Drawing;
using System.Net;
using System.Text;
using System.Windows.Forms;

class MainClass
{
   private static void Resolved(IAsyncResult ar)
   {
      string buffer;

      IPHostEntry iphe = Dns.EndResolve(ar);

      buffer = "Host name: " + iphe.HostName;
      Console.WriteLine(buffer);

      foreach(string alias in iphe.Aliases)
      {
         buffer = "Alias: " + alias;
         Console.WriteLine(buffer);
      }
      foreach(IPAddress addrs in iphe.AddressList)
      {
         buffer = "Address: " + addrs.ToString();
         Console.WriteLine(buffer);
      }
   }

   public static void Main()
   {
      AsyncCallback OnResolved;

      OnResolved = new AsyncCallback(Resolved);

      string addr = "www.java2s.com";
      Object state = new Object();

      Dns.BeginResolve(addr, OnResolved, state);
   }
}

   
    
  








Related examples in the same category

1.Dns.GetHostByAddress(IPAddress ip)
2.Dns.GetHostByName
3.Dns.GetHostEntry(String value)
4.Dns.GetHostName()
5.Dns.Resolve