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