Fri, 17 May 2024


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

By: Anton, NetArt Media
Mon, 28 March 2022

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: Web Development
Share this post:



See All Scripts






Subscribe for our newsletter

Receive the latest blog posts direct in your mailbox