php sockets

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fricx
Forum Newbie
Posts: 2
Joined: Wed May 07, 2008 9:58 am

php sockets

Post by fricx »

Hello,

I am making a script that will connect to udp port of my counter strike 1.6 server and that will be able to change stuff via rcon commands.

The problem is that RCON protocol has some requirements witch you can see in the following code:

Code: Select all

function rcon ($ip, $port, $rcon_pass, $command) {
 
        $fp = fsockopen("udp://$ip",$port, $errno, $errstr, 2);
        socket_set_timeout($fp,2);
 
        if (!$fp)       {
                echo "$errstr ($errno)<br>\n";
        } else {
                $query = "\xFF\xFFrcon\x00". $rcon_pass . "\x00" . $command . "\x00\x00";
                fwrite($fp,$query);
        }
 
        fclose ($fp);
}  


Here is the problem:

Code: Select all

$query = "\xFF\xFFrcon\x00". $rcon_pass . "\x00" . $command . "\x00\x00";
RCON requests this " \xFF\xFFrcon\x00 " codes and for every game is different. I found it for cs:source but not for cs 1.6.

If anyone knows how to connect to gameserver rcon and send commands through it please help =))
Thank you !!!
fricx
Forum Newbie
Posts: 2
Joined: Wed May 07, 2008 9:58 am

Re: php sockets

Post by fricx »

Anyone?
Post Reply