Sunday, 21 September 2014

IP Address Retrieval


                                     Retrieving The current IP addresses

The folliowing code explains how to retrieve the IP adddesses that used to acces the network


static void retrieveip(Args _args)
{
System.String hostName = System.Net.Dns::GetHostName();
System.Net.IPHostEntry hostEntry = System.Net.Dns::GetHostEntry(hostName);
System.Net.IPAddress[] addresses = hostEntry.get_AddressList();
System.Net.IPAddress address;
System.Net.Sockets.AddressFamily addressFamily;
System.Collections.IEnumerator enumerator = addresses.GetEnumerator();

while (enumerator.MoveNext())
{
address = enumerator.get_Current();
addressFamily = address.get_AddressFamily();
if (addressFamily == System.Net.Sockets.AddressFamily::InterNetwork)
{
info(address.ToString());
}
}
}


compile and run the code ,,,,,,,,,,,,,,,,,

No comments:

Post a Comment