OFFICIAL WEBSITESTORE WIKI News General Version Discussion Feedback Guild Custom Servers
Login   Register
View: 641|Reply: 1

Dedi server Query protocol

Novice on the road

4

Threads

4

Posts

4

Threads
Posted 1-14-2024 07:41:52
Does anyone know the query protocol for getting game stats via the query port?
Reply

Use magic Report

Novice on the road

0

Threads

1

Posts

0

Threads
Posted 10-4-2024 11:22:58
Determine the protocol used by the game server you want to query. This information can often be found in the game's documentation or community forums.
Use a UDP socket to connect to the query port of the game server. The query port is typically a well-known port number, such as 27015 for Source Engine games.
Send a query packet to the server, formatted according to the specific protocol. The packet typically includes information like the query type (e.g., "info", "players", "rules") and other parameters.
The server will respond with a packet containing the requested game stats. The format of the response will also depend on the protocol.

Example:
  1. <div>import socket</div><div>
  2. </div><div># Create a UDP socket</div><div>sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)</div><div>
  3. </div><div># Send a query packet</div><div>sock.sendto(b"info\0", ("gameserver.example.com", 27015))</div><div>
  4. </div><div># Receive a response</div><div>data, addr = sock.recvfrom(1024)</div><div>
  5. </div><div># Print the response</div><div>print(data.decode())</div><div>
  6. </div>
Copy the Code


Reply

Use magic Report

English

Quick Reply To Top Return to the list