how can i read the ip addresses where are presently renning in network
Printable View
how can i read the ip addresses where are presently renning in network
using System;
using System.Net;
namespace GetIPCS
{
/// <summary>
/// Gets IP addresses of the local machine
/// </summary>
class classGetIPCS
{
/// <summary>
/// Gets IP addresses of the local machine
/// </summary>
[STAThread]
static void Main(string[] args)
{
// Get host name
String strHostName = Dns.GetHostName();
Console.WriteLine("Host Name: " + strHostName);
// Find host by name
IPHostEntry iphostentry = Dns.GetHostByName(strHostName);
// Enumerate IP addresses
int nIP = 0;
foreach(IPAddress ipaddress in iphostentry.AddressList)
{
Console.WriteLine("IP #" + ++nIP + ": " +
ipaddress.ToString());
}
}
}
}