Because the friend said the port is not connected, deliberately tried the ping test with PHP, the result is quite satisfactory.
The code and the run diagram are as follows: (if there is a great God to improve the better)
<?php
$host = ' www.php100.com ';
$port = ' 80 ';
$num = 3; Ping times
Get time
function Mt_f () {
List ($usec, $sec) = Explode ("", Microtime ());
Return ((float) $usec + (float) $sec); Microseconds plus seconds
}
function Ping_f ($host, $port) {
$time _s = Mt_f ();
$ip = gethostbyname ($host);
$fp = @fsockopen ($host, $port);
if (! $fp)
Return to ' reply time out! ';
$get = "Get/http/1.1\r\nhost:" $host. " \r\nconnect: ". $port." Close\r\n ";
Fputs ($fp, $get);
Fclose ($FP);
$time _e = Mt_f ();
$time = $time _e-$time _s;
$time = Ceil ($time * 1000);
Return to ' reply from '. $ip. ': $port. ' time = '. $time. ' Ms<br/> ';
}
echo ' ping to '. $host. ' ['. gethostbyname ($host). '] With Port: '. $port. ' Data:<br/> ';
for ($i = 0; $i < $num; $i + +) {
Echo Ping_f ($host, $port);
1S per run intermediate interval
Sleep (1);
Refreshing output caching
Ob_flush ();
Flush ();
}
?>