Jump to content

Querying A Game Server


LejeuneBay

Recommended Posts

Good Afternoon,

 

I am currently trying to query a game server, I have searched the web for help for the last two weeks and have found nothing helpful. So far, I am able to query my personal game server; however, I do not always get the results I expect. In this case, I am trying to query a game server on the following video game: "Command and Conquer Renegade". Here is what I have in my test code:

 

 

set_time_limit (108000); // Let run for an hour
function microtime_float()
{
   list($usec, $sec) = explode(" ", microtime());
   return ((float)$usec + (float)$sec);
}
$time_start = microtime_float();
/* SOURCE ENGINE QUERY FUNCTION, requires the server ip:port */
function source_query($ip, $command, $len)
{
$cut = explode(":", $ip);
$address = $cut[0];
$port = $cut[1];
$socket = fsockopen($address, $port, $errno, $errstr);
$query = $command;
fwrite($socket, $command);
stream_set_timeout($socket, 108000);
$result = fread($socket, $len);
$info = stream_get_meta_data($socket);
fclose($socket);

if ($info['timed_out']) {
 echo 'Timed out';
} else {
 $result = urldecode($result); // the output
 echo $ip." - <b>COMMAND: <font color=red>".$command."</font></b>".$result."<br><br><hr>";
}
}
$command = array("\xFF\xFF\xFF\xFFgetstatus\x00", "0x0");
for($x = 0; $x < count($command); $x++)
source_query($_GET['ip'], $command[$x], 2500);


$time_end = microtime_float();
$time = $time_end - $time_start;
echo"<b>EXECUTED IN: </b>".$time;

 

 

Now what exactly am I doing wrong, and is there any good websites that have information on how to properly query a game server?

 

Cheers,

Ryan

Link to comment
https://forums.phpfreaks.com/topic/269259-querying-a-game-server/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.