Search code examples
delphiminecraftindy10bukkit

Query to online game server to get its status Delphi - Indy 10


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.


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...