|
-
April 24th, 2005, 03:32 AM
#1
reading ip address
how can i read the ip addresses where are presently renning in network
-
April 24th, 2005, 08:11 AM
#2
Re: reading ip address
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());
}
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|