26.02.2010, 03:04
Quote:
Originally Posted by D00Mpy
For the people that are searching for this.
Here is the code that works: I took GamerX as example, because it was the first in my favorite list :P Makers: D00Mpy and Norn Код:
<?php $server = "217.18.70.90"; // GamerX $port = 8800; $socket = fsockopen('udp://'.$server, $port, $iError, $sError, 2); if(!$socket) { exit("Connection Failed"); } stream_set_blocking($socket, 1); $sPacket = 'SAMP'; $sPacket .= chr(strtok($server, '.')); $sPacket .= chr(strtok('.')); $sPacket .= chr(strtok('.')); $sPacket .= chr(strtok('.')); $sPacket .= chr($port & 0xFF); $sPacket .= chr($port >> 8 & 0xFF); $sPacket .= 'p4150'; $start = microtime(true); fwrite($socket, $sPacket); $data = fread($socket, 15); $end = microtime(true); $ping = ($end - $start) * 1000; $ping = floor($ping); echo $ping; fclose($socket); ?> |