Archive for November, 2009

Using the Rcon protocol with Python

26-11-2009 Alec Hussey 4 Comments

Within the PC gaming community, it is quite useful to be able to control or monitor your servers programmatically. The almost universal standard being Rcon or “Remote Connection.” The protocol is overall very simple, it only requires a standard UDP socket and that you send a packet header with the login credentials per each request you make.

We will start by importing the python socket module and creating a UDP connection to the server.

import socket
 
if __name__ == "__main__":
   sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 
   # Connect to CoD4 server at 8.9.17.24:28960
   # Will also work for most other games in a similar fasion
   sock.connect(("8.9.17.24", 28960))

(more…)

Filed under:
Tags: , , , ,