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
Ip address
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Bechir BejaouiRank #144 · 15.9K pointsPosted Jul 26, 2008, 1:49 PM EDT
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