Server Admin Port Development
The Server Admin Port is available to be connected to from any programming language that has support for sockets. The documentation contained within this page is aimed at helping you get started developing a client (or library).
- JOAN is an example written in Java that can do almost everything that the Admin Port offers.
- COAN is an example written in C# that is more limited in it's abilities but still offers the basics.
Both of these projects are open source so can be used freely by anyone wishing to write their own Client for the OpenTTD server admin port.
(Please add your own to this list if they are freely available and/or Open Source)
To be able to connect to the Admin Port on your server there are a couple of things you need to have done.
- You will need to set the server_admin_port in Openttd.cfg. This can be anywhere between 0-65535 but must *NOT* be in use by any other programs
- You will also need to ensure that you have set the Admin password
- This is very important because if you do not set the Admin Password OpenTTD will *NOT* start a listener for the Admin Port
Connecting to Admin Port
Once you have got the basics above set up you can now connect.
At this stage you can choose to create your own library if there is not already one your chosen language or you can use on of the existing libraries (see libraries above).
JOAN comes with an example in the form of SimpleConsole which extends the OpenTTD class. While COAN comes with a very limited WinForms application to play with.
Creating your own
Connecting to the admin port requires sending a ADMIN_PACKET_ADMIN_JOIN packet to your server.
The format of packets sent to the Admin Port are expected to be:
SIZE | TYPE | DATA
When you wish to connect your packet would be something like: 0x1B 0x00 + 0x00 + "password" + 0x00 + "botname" + 0x00 + "version" + 0x00
|Total Size||27 Bytes (0x1B)|
It is very important to remember to prepend the packet with the size of the packet (remember to +2 for the packet size bytes). In the example above the payload (Type and data is 25 bytes. The +2 for packet size makes it 27)
There are multiple packets which are used to achieve different purposes. While these are mostly self explanatory below is a quick reference.