Skip to content
frostschutz edited this page Sep 14, 2010 · 2 revisions

SourceRcon implements the Source Server RCON Protocol as described here: Source_RCON_Protocol

It supports sending commands to the server and receiving the command output.

While the protocol has no real indication of whether the output is split over multiple packets, a heuristic is used that only keeps listening for additional packets when the probability for such packets is high. This way, receiving even long responses such as the cvarlist usually works without an unnecessary wait for a packet that may never come.

The class opens the necessary TCP connection to the server automatically and tries to reuse it for as long as possible. This is good for sending more than just one command (for example executing whole scripts via rcon), but suboptimal for single commands. If you know that the connection won’t be used anymore, you should therefore close it manually.

Example usage:


import SourceRcon server = SourceRcon.SourceRcon('1.2.3.4', 27015, 'secret') print server.rcon('status') print server.rcon('cvarlist') script = open('script.cfg') server.rcon(script.read())
Clone this wiki locally