anton zamov it expert logo    

home page latest news web development curriculum vitae consulting contact me


  • Curriculum Vitae (CV)
  • Major web solutions
  • Web design projects
  • Software solutions


  • C# (Microsoft .NET)
  • JAVA
  • Dynamic HTML
  • PHP & MySQL
  • ASP.NET - C# & VB.NET
  • Perl & CGI
  • C | C++
  • Vector Markup Language
  • SMIL
  • Assembler
  • Databases
  • Wap Development
  • Web site promotion
  • Web Marketing


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

(C# free example written by Anton Zamov.
Need a professional consulting or development service? Click here!)

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)
{
/*
This method is created by Anton Zamov.web site: http://zamov.online.fr

Feel free to use and redistribute this method in condition that you keep this message intact.
*/

            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;
}





Copyright © Anton Zamov 1998 - 2023