Game Server Library

The GameServer library provides tools for Java applications to query server information from popular game servers.

Downloads and Documentation


Supported Games

Game Engine Basic Info. Players Rules Rcon Server List Example Games
Battlefield: Bad Company 2 Y β
Left 4 Dead Y β β α Left 4 Dead 1, Left 4 Dead 2
Orange Box Y β β α Age of Chivalry, Day of Defeat: Source, Garry's Mod, Synergy, Team Fortress 2, Zombie Panic! Source
Source Y β β α β Counterstrike: Source, Half-Life 2
Battlefield 1942 Y Y β β
Unreal Engine 2 Y β Y America's Army, Killing Floor, Unreal Tournament 2003, Unreal Tournament 2004
Unreal Engine 1 Y Y β β Unreal, Unreal Tournament
Gold Source Y Y Y α β Half-Life 1

Legend: Y=Full functionality; β=Full functionality, but not yet optimized; α=Partial functionality that may be rewritten

Third-party Service Aggregation




These libraries are required for the basic functioning of this library. This will provide you with JavaBean-like objects.

  • Java v6
  • Commons Logging v1.1.1 or later (commons-logging-1.1.1.jar)
  • JDOM v1.0 or later (jdom.jar)

XML Conversion

This library is required for conversion to XML. This will provide you with JDOM Documents.

Rcon Administration

This library is required to use the Rcon interface on Valve-based servers.

  • RconEd v2.0 or later (RconEd.jar)


This library is completely optional, but will make master server list retrieval faster. It will allow the DNS lookups of the master server to be cached.

  • dnsjava v1.5.0 or later


Invoke the close() Method

The servers based on UdpServer are cached internally. To retrieve the cached copy of the server, use the getInstance() method. To replace the cached version with a new instance, use the new keyword. To remove the instance from cache, invoke the close() method.

Use Asynchronous Methods

If you need to do multiple queries on the same or multiple servers, it's good to do so asynchronously. By adding a listener and invoking methods that do not contain timeout parameters, you can send a query which will return immediately. Your listener will be called when your queries are complete.


These examples are shown with no error handling for simplicity.

Error Handling

SourceServer server = SourceServer.getInstance(new InetSocketAddress("", 27015));
server.addListener(new Listener () {
	public void errorHandler(Throwable error, GameServer server) {
		System.err.println("Error querying: " + server);


InetSocketAddress addr = new InetSocketAddress("", 27015);
SourceServer server = SourceServer.getInstance(addr);
try {
	server.load(2000, Request.INFORMATION, Request.PLAYERS, Request.RULES);
} finally {

Server List

SourceServerList list = new SourceServerList();
list.gameDir = "synergy";
HashSet<SourceServer> serverList = new HashSet<SourceServer>();
ValveServerList<SourceServer>.ServerIterator servers = list.iterator(10000);
try {
	while (servers.hasNext()) {
		SourceServer server =;
} finally {
for (SourceServer server: serverList) {

To Do List

  • Add support for gametype
  • Redesign RCON support
  • Properly extend Player class for specific games, rather than putting all the properties in the main Player class
  • Support Stats ID in Unreal Engine 2 servers
  • Verify length and checksum of bziped replies
  • Replicate SourceServerList to support Left 4 Dead and Orange Box