Hello,
I'm trying to figure a way where my clients can ping my server via php, and then retrieve the results into format like this "15 MS".
I ended up finding a way where servers can ping servers. However I want to be able to have the remote user somehow ping the server, or maybe have the server ping the client possibly?
function track($host, $port, $timeout) {
$firstTime = microtime(true);
$sock = fSockOpen($host, $port, $errno, $errstr, $timeout);
if (!$sock) {
echo "<b>Offline</b>";
}
$secondTime = microtime(true);
$ping = round((($secondTime - $firstTime) * 1000), 0);
echo $ping." ms";
}
track($_SERVER["REMOTE_ADDR"], 80, 10);
I tried this function, where I'd get the server to ping the client to see the response time between the client/server.
fsockopen() [function.fsockopen]: unable to connect to XXXXXXXXXXX:80