Ragazzi non so se esiste effettivamente una funzione ping tuttavia ho pensato che se ne potesse simulare una con i socket... vi piazzo quella che ho fatto... mi date una mano a perfezionarla??

Codice PHP:
function ping($host,$port=80,$timeout=30,$pings=1,$fullreport=0)
{
for(
$i=0;$i<$pings;$i++) {
$mtime microtime();
$mtime explode(" ",$mtime);
$mtime $mtime[1] + $mtime[0];
$starttime $mtime;
$ping[$i]["open"]=fsockopen($host,$port,$ping[$i]["error_no"],$ping[$i]["error"],$timeout);
$ping[$i]["close"]=fclose($ping[$i]["open"]);
$mtime microtime();
$mtime explode(" ",$mtime);
$mtime $mtime[1] + $mtime[0];
$endtime $mtime;
$ping[$i]["ping"] = round(($endtime $starttime)*1000);
}
if(
$pings==&& $fullreport==0) {$ping=$ping[0]["ping"];}
return 
$ping;
}

echo 
ping("www.html.it");