Created
September 13, 2012 14:15
-
-
Save msysyamamoto/3714592 to your computer and use it in GitHub Desktop.
Interval to check liveness.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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