1//Check whether the node is alive or not. If alive, return the IP.
2 protected static string CheckNodeConnectivity (string hostName)
3 {
4 bool nodeIsAlive=false;
5 string nodeIP = string.Empty;
6 using (Ping ping=new Ping() )
7 {
8 try
9 {
10 PingReply reply = ping.Send(hostName, 600); //600 ms
11 if (reply.Status ==IPStatus .Success )
12 {
13 nodeIsAlive = true;
14 nodeIP = reply.Address.ToString();
15 }
16 }
17 catch (Exception err)
18 {
19 // Console.WriteLine("Error has occurred in method CheckNodeConnectivity: " +err.Message );
20 }
21
22
23 }
24 return nodeIP;
25 }