TextToBeWritten = "
Pinging...
"; 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 += "
Offline
" + ip + "
"; else { //Machine is alive TextToBeWritten += "
Online
" + ip + "
"; IPAddress hostIPAddress = IPAddress.Parse(ip); TextToBeWritten += "
"; 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 += "
"; } }