say i was only given port numbers of all running servers in a particular LAN network.
Any hint on how to obtained the corresponding ip addresses for these ports?
Thanks in advance
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Bechir BejaouiPosted Jul 26, 2008, 5:49 PM
private static void GetAllIPAdresses(string[] Servers)
{
try
{
string[] ServerNames = Servers;
int index = 0;
System.Net.IPHostEntry[] oEntry;
IPAddress[] ipAdresses;
for (index = 0; index < ServerNames.Length; index++)
{
oEntry[index] = Dns.GetHostByName(ServerNames[index]);
IPAddress[] ipAdresses = oEntry[index].AddressList;
foreach (IPAddress ip in ipAdresses)
{
Console.WriteLine(ip.Address.ToString());
}
}
Console.Read();
}
catch (System.Net.Sockets.SocketException caught) { Console.WriteLine(caught.Message);Console.Read();}
}
I 'm not sure that it work but It certainly saves some efforts