Issue
Code backup
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
TextToBeWritten = "<div>Pinging... </div>";
|
||||
|
||||
string ipBase = "172.16.94.";
|
||||
for (int i = 1; i < 100; i++)
|
||||
{
|
||||
string ip = ipBase + i.ToString();
|
||||
|
||||
Ping p = new Ping();
|
||||
var pingReply = p.Send(ip, 100);
|
||||
|
||||
|
||||
|
||||
if (pingReply.Status != IPStatus.Success)
|
||||
TextToBeWritten += "<div><div class=\"host-offline\">Offline</div>" + ip + "</div>";
|
||||
else
|
||||
{
|
||||
//Machine is alive
|
||||
TextToBeWritten += "<div><div class=\"host-online\">Online</div>" + ip + "</div>";
|
||||
|
||||
IPAddress hostIPAddress = IPAddress.Parse(ip);
|
||||
TextToBeWritten += "<div>";
|
||||
try
|
||||
{
|
||||
IPHostEntry hostInfo = Dns.GetHostByAddress(hostIPAddress);
|
||||
IPAddress[] address = hostInfo.AddressList;
|
||||
String[] alias = hostInfo.Aliases;
|
||||
TextToBeWritten += "Host: " + hostInfo.HostName;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TextToBeWritten += "DNS Resolution Error: " + e.Message;
|
||||
}
|
||||
TextToBeWritten += "</div>";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user