Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 141337

Ping (Latency) request from client-browser, not from webhosting

$
0
0

I wonder how to change the code so that the demand does not come from webhosting, but from client-browser and in this case show how many "ms" the corresponding client-browser has to a particular website/server

<?
function ping($host, $port, $timeout) { 
  $tB = microtime(true); 
  $fP = fSockOpen($host, $port, $errno, $errstr, $timeout); 
  if (!$fP) { return "Server is down"; } 
  $tA = microtime(true); 
  return round((($tA - $tB) * 1000), 0)." ms"; 
}

//Echoing it will display the ping if the host is up, if not it'll say "down".
echo ping("google.com", 80, 10); 
?>

Viewing all articles
Browse latest Browse all 141337

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>