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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.