문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top