Question

I am trying to find out how to establish a connection between a Delphi application and an online game server in this case Minecraft running with Bukkit.

The search was not successful, but I have a vague idea using maybe Indy 10 components? like TIdTCPClient but I think it needs a handler, I dont know which one.

Then I want to ask.

How to query an online server?

With PHP: https://github.com/FunnyItsElmo/PHP-Minecraft-Server-Status-Query

Any idea coming up?

Sorry for my English Thanks.

Was it helpful?

Solution

As MJN said, once you Connect() to the server, you use the TIdIOHandler.IOHandler property to read/write data as needed, eg:

var
  data: TIdBytes;

Client.Host := AHost;
Client.Port := APort;
Client.ConnectTimeout := 3000;
Client.ReadTimeout := 3000;

Client.Connect;
try
  Client.IOHandler.Write(Byte($FE));
  Client.IOHandler.Write(Byte($01));
  Client.IOHandler.ReadBytes(data, 2048);
finally
  Client.Disconnect;
end;

// parse data as needed...

OTHER TIPS

There is no additional "Handler" required for TIdTCPClient to connect with the server.

A TIdTCPClient instance contains an IOHandler (exposed as a property).

Use this IOHandler to read bytes from the server.

The PHP source code for Minecraft server status queries seems to be quite short and easy to understand, it will be no problem to port it to Delphi.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top