Query Mechanism
#14

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);
?>
Two heads are better than one!
Reply


Messages In This Thread
Query Mechanism - by [nl]daplayer - 26.02.2010, 01:18
Re: Query Mechanism - by Norn - 26.02.2010, 01:31
Re: Query Mechanism - by [nl]daplayer - 26.02.2010, 01:34
Re: Query Mechanism - by Norn - 26.02.2010, 01:37
Re: Query Mechanism - by [nl]daplayer - 26.02.2010, 01:40
Re: Query Mechanism - by Norn - 26.02.2010, 01:45
Re: Query Mechanism - by [nl]daplayer - 26.02.2010, 01:47
Re: Query Mechanism - by Norn - 26.02.2010, 01:58
Re: Query Mechanism - by [nl]daplayer - 26.02.2010, 02:08
Re: Query Mechanism - by Norn - 26.02.2010, 02:25
Re: Query Mechanism - by [nl]daplayer - 26.02.2010, 02:31
Re: Query Mechanism - by Norn - 26.02.2010, 02:32
Re: Query Mechanism - by [nl]daplayer - 26.02.2010, 03:00
Re: Query Mechanism - by Norn - 26.02.2010, 03:04

Forum Jump:


Users browsing this thread: 2 Guest(s)