Skip to content

Instantly share code, notes, and snippets.

@msysyamamoto
Created September 13, 2012 14:15
Show Gist options
  • Save msysyamamoto/3714592 to your computer and use it in GitHub Desktop.
Save msysyamamoto/3714592 to your computer and use it in GitHub Desktop.
Interval to check liveness.
<?php
$hostname = '192.168.0.100';
$port = 80;
$timeout = 10;
$sock = fsockopen($hostname, $port, $errono, $errstr, $timeout);
if ($sock === false) {
exit("{$errstr} ({$errono})\n");
}
echo "connect {$hostname}:{$port}\n";
$start = microtime(true);
echo "start: {$start}\n";
fgets($sock);
$end = microtime(true);
fclose($sock);
echo " end: {$end}\n";
echo " time: " . ($end - $start) . "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment