public function Open( )
{
if( !$this->RconSocket )
{
$this->RconSocket = @FSockOpen( $this->Socket->Address, $this->Socket->Port, $ErrNo, $ErrStr, $this->Socket->Timeout );
if( $ErrNo || !$this->RconSocket )
{
throw new SocketException( 'Can\'t connect to RCON server: ' . $ErrStr, SocketException::CONNECTION_FAILED );
}
Stream_Set_Timeout( $this->RconSocket, $this->Socket->Timeout );
Stream_Set_Blocking( $this->RconSocket, true );
}
}
import valve.rcon
address = ("192.168.0.101", 27015)
password = "123123"
with valve.rcon.RCON(address, password) as rcon:
response = rcon.execute("echo Hello, world!")
print(response.text)
import valve.rcon
server_address = ("192.168.0.101", 27015)
password = "123123"
with valve.rcon.RCON(server_address, password) as rcon:
rcon.execute("echo Hello, world!")