1
0
mirror of https://gitlab.com/JKANetwork/CheckServer.git synced 2026-03-12 21:42:02 +01:00

Don't throw too much errors if not root ping

This commit is contained in:
2020-10-17 13:39:24 +02:00
parent b907ed0765
commit 2e88377665
2 changed files with 12 additions and 8 deletions

View File

@@ -164,7 +164,10 @@ function ping($ip, $timeout = 2,$rTimes = 2) {
while ($retry < $rTimes){ //Retry rTimes times if fail
//Create ICMP socket and see if works
$package = "\x08\x00\x7d\x4b\x00\x00\x00\x00PingHost";
$socket = socket_create(AF_INET, SOCK_RAW, 1);
$socket = socket_create(AF_INET, SOCK_RAW, 1);
if ($socket == FALSE){ //If not works, please don't continue.
break;
}
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => $timeout, 'usec' => 0));
socket_connect($socket, $ip, null);