admin port
Moderator: OpenTTD Developers
admin port
Hi,
I would like to make php library for comunicating via admin port. It shouldnt be much hard, but I failed to comunicate with server, what is quite a major problem. There is little documentation about what actually send, and I cant extract from already done libraries in jave or python.
So, is there some nice site, where is exactly said what data pack and send?
My problem is: I want to join as admin, so I have a server with admin password "password", and port is 3977.
I am sending packet 0x00 + "password" + 0x00 + "botname" + 0x00 + "version" + 0x00
But nothing is received.
I would like to make php library for comunicating via admin port. It shouldnt be much hard, but I failed to comunicate with server, what is quite a major problem. There is little documentation about what actually send, and I cant extract from already done libraries in jave or python.
So, is there some nice site, where is exactly said what data pack and send?
My problem is: I want to join as admin, so I have a server with admin password "password", and port is 3977.
I am sending packet 0x00 + "password" + 0x00 + "botname" + 0x00 + "version" + 0x00
But nothing is received.
Re: admin port
As I mentioned already in your other thread, the documentation of the admin port is here:
http://vcs.openttd.org/svn/browser/trun ... etwork.txt
If something you need is missing from the documentation, I'm afraid you will need to check OpenTTD source code (somewhere in src/network IIRC) or wait for someone who knows about the admin network to answer here.
http://vcs.openttd.org/svn/browser/trun ... etwork.txt
If something you need is missing from the documentation, I'm afraid you will need to check OpenTTD source code (somewhere in src/network IIRC) or wait for someone who knows about the admin network to answer here.
Spanish translation of OpenTTD
Extended heightmaps
Have fun, don't quarrel too much and add as many advanced settings as you can.
Extended heightmaps
Have fun, don't quarrel too much and add as many advanced settings as you can.
Re: admin port
A packet should contain it's size on the first two bytes (LE). Your packet has...
- size - 2 bytes
type - 1 byte
"password" - 9 bytes
"botname" - 8 bytes
"version" - 7 bytes
----------------------
= 27 bytes (0x1B bytes)
- 0x1B 0x00 + 0x00 + "password" + 0x00 + "botname" + 0x00 + "version" + 0x00
don't worry, be happy and checkout my patches
Re: admin port
thanks adf88, I will try it, seems this really could be it
Terkhen, I read that, it is good, but doesnt go to details about the packet consist as you probably know too.
Terkhen, I read that, it is good, but doesnt go to details about the packet consist as you probably know too.
Re: admin port
Sorry but as I mentioned I don't know much about the admin network. Your best bet is the source code then.
Spanish translation of OpenTTD
Extended heightmaps
Have fun, don't quarrel too much and add as many advanced settings as you can.
Extended heightmaps
Have fun, don't quarrel too much and add as many advanced settings as you can.
Re: admin port
ok, so it works, already getting some packets from server. This admin port is sure a cool thingy
Re: admin port
JOAN has a lot of example code that you will be able to port to PHP quite easily. In fact JOAN example code could be ported quite easily to almost any language if you know what you are doing in the that language.
My Patches: Lifetime profit patch | Improved Shares [ON HIATUS]
Re: admin port
Thats true. Right now I can access server very easily, but major problem is handling TCP socket. My code is too much slow. Unfortunately, this cant be transfered from java
Re: admin port
What's the reason for needing to use PHP as opposed to Java? Hit me up on MSN if you want I've got some PHP experience so I might be able to give you some help.
My Patches: Lifetime profit patch | Improved Shares [ON HIATUS]
Re: admin port
burty wrote:What's the reason for needing to use PHP as opposed to Java?
Reason is to gain control via web. Although java can be useful here, I would rather do it in php.
So I have this code:
Code: Select all
<?php
public function connect(){
$this->socket = fsockopen($this->host,$this->port); //open socket
//stream_set_blocking( $this->socket, false); //non blocking stream
}
public function send_packet($type, $subtype=""){
$this->type = $type;
if($subtype) $this->subtype = $subtype;
$this->packet = new APacket();
$this->send_prepare();
fwrite($this->socket, $this->packet->send(), APcontrol::SEND_MTU);
}
public function recv_packet(){
$output = "";
while(($output .= fread($this->socket, APcontrol::SEND_MTU))){
}
$this->packet->recv_start($output);
$this->recv_analyze();
}
?>
I am able to connect, to send query, even recieve, but recieving takes a lot of time, 10+ secons, sometimes even more than php timeout. TCP should be able to do it much faster, so obviously I missed some vital thing.
With stream blocking it outpust nothing.
Any help would be very appreciated.
Re: admin port
Does the admin port receive the map? If it does, that code is way too slow - you're string concatenating on each byte. If you receive large packets you'd be better off creating a buffer array and reading a chunk at a time.
You should time whether it finished the read or if your own receiving functions are the bottleneck.
You should time whether it finished the read or if your own receiving functions are the bottleneck.
Creator of the Openttd Challenge Spinoff, Town Demand patch
After action reports: The path to riches, A dream of skyscrapers
After action reports: The path to riches, A dream of skyscrapers
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: admin port
No.Korenn wrote:Does the admin port receive the map?
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: admin port
No map. Recieveing data are not more than aproximately 500 bytes, if game is full.
Re: admin port
Thanks for the info! I had the same problem as Honza_. I am planning to write an interface to the admin port for personal use (and fun) in the Lua programming language. The documentation at http://svn.openttd.org/trunk/docs/admin_network.txt is clear, but it doesn't tell a packet should contain its size which is essential information. My elementary program is now able to communicate with the server through the admin port and is able to grow...adf88 wrote:A packet should contain it's size on the first two bytes (LE). Your packet has...
...so what you should send is
- size - 2 bytes
type - 1 byte
"password" - 9 bytes
"botname" - 8 bytes
"version" - 7 bytes
----------------------
= 27 bytes (0x1B bytes)
- 0x1B 0x00 + 0x00 + "password" + 0x00 + "botname" + 0x00 + "version" + 0x00
Either adding the packet's size is obvious and I am stupid or the documentation should be updated. It took me hours of Googling and reading this forum before I found this thread and found out what I did wrong. If the documentation should be updated, who can I contact?
Who is online
Users browsing this forum: No registered users and 50 guests