×
Home About Us Products Services News Free Scripts Contact
news php scripts and software

C# (C Sharp) example - How to get a list of IP addresses associated with a host?


C# (C Sharp) - How to get a list of IP addresses associated with a host?

How to get a list of IP addresses associated with a host?

The method listed below returns a string array containing IP addresses that resolve to the host name.

public string[] getIPList(string hostName)
  {


          IPHostEntry IpEntry=new IPHostEntry();

          int counter = 0;

          string[] strResult=new string[100];

  try

  {

          foreach(IPAddress Ip in iphostentry.AddressList)

  {
          strResult[counter++]=Ip.ToString()

  }
  
  }
                  
  catch(Exception exc)

                  
  {
          // TODO

  }

  return strResult;
  }

Category: C# (C Sharp)

 
<< Go back