public string[] Ping(string IP) { ping.count = 0; ping.success = 0; ping.failure = 0; //regular expression to validate an ip Regex ipRgx = new Regex(@"^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$"); if (!ipRgx.IsMatch(IP)) { Debug.LogAssertion(id + ": Invalid IP address; Check format"); return(null); } //start pinging while (ping.count < 4) { sendPacket(ping.Echo(IP)); ping.count++; /*if (!sendPacket(ping.Echo(IP))) * { * ping.count++; * } else * { * ping.count++; * } */ } //determine pass/fail ping.failure = ping.count - ping.success; Debug.LogAssertion("PING: Successful: " + ping.success); Debug.LogAssertion("PING: failed: " + ping.failure); string[] results = new string[3]; results[0] = ping.count.ToString(); results[1] = ping.success.ToString(); results[2] = ping.failure.ToString(); return(results); }