4 $package = "\x08\x00\x19\x2f\x00\x00\x00\x00\x70\x69\x6e\x67";
6 /* create the socket, the last '1' denotes ICMP */
7 $socket = socket_create(AF_INET
, SOCK_RAW
, 1);
9 /* set socket receive timeout to 1 second */
10 socket_set_option($socket, SOL_SOCKET
, SO_RCVTIMEO
, array("sec" => 3, "usec" => 0)); //<-- Change TimeOut Here <--
12 /* connect to socket */
13 socket_connect($socket, $host, null);
15 /* record start time */
16 list($start_usec, $start_sec) = explode(" ", microtime());
17 $start_time = ((float) $start_usec +
(float) $start_sec);
19 socket_send($socket, $package, strlen($package), 0);
21 if(@socket_read
($socket, 255)) {
22 list($end_usec, $end_sec) = explode(" ", microtime());
23 $end_time = ((float) $end_usec +
(float) $end_sec);
25 $total_time = $end_time - $start_time;
32 socket_close($socket);
36 function readline ( $fp ) {
44 if ($c == "\n") { // && ($c == "\r") //May be later on oher systems
58 //echo (ping ("192.168.2.1"));
59 $fp = fopen("hosts.txt", "r+"); //host list file (hosts separated by newline, ends with two empty lines)
62 while ($fhost != "") {
65 $fhost = trim(readline($fp));
68 echo("HOST: ".$fhost);
72 } catch(string $err) {}
74 if ( ($ping != "") && ($ping > "0") ) {
75 echo(" - UP PING: ".$ping." sec.\n");
77 echo (" - TIMED OUT\n");
This page took 0.490099 seconds and 4 git commands to generate.