Originally adapted from the PHP implementation featured here.
This implementation listens for HTTP GET requests on localhost:8181 and passes the command query onto the rcon connection, which is kept alive. A ping command is sent regularly to ensure that the connection is still active, although whether this is strictly necessary is debatable.