var
reqid :integer =0;
const
SERVERDATA_EXECCOMMAND = 2;
SERVERDATA_AUTH = 3;
function ContructPacket(id, cmdtype: integer; s1,s2:
string) :
string;
var
data: TStringStream;
packetlength: integer;
ende: byte;
begin
//leeres byte
ende:= 0;
//ContructPacket
data := TStringStream.Create('
');
try
//Länge festlegen
data.Size:= 4+4+4+length(s1)+1+length(s2)+1;
//Paketlänge errechnen (-4 da Paketlänge nicht mitgerechnet wird)
packetlength:= data.Size-4;
data.Position:= 0;
data.
Write(packetlength,sizeof(INTEGER));
data.
Write(id,sizeof(INTEGER));
data.
Write(cmdtype,sizeof(INTEGER));
data.WriteString(s1);
data.
Write(ende,sizeof(byte));
data.WriteString(s2);
data.
Write(ende,sizeof(byte));
result:= data.DataString;
reqid:= reqid+1;
finally
data.Free;
end;
end;
procedure TForm1.Button5Click(Sender: TObject);
var
temp:
string;
begin
//IP und Port sind fest in der Komponente eingetragen
IdUDPClient1.Active:= True;
IdUDPClient1.Connect;
ActiveSleep(5);
//nur sleep mit application.ProcessMessages;
IdUDPClient1.Send(ContructPacket(reqid,SERVERDATA_AUTH,'
RconPasswort','
'));
ActiveSleep(10);
temp:= IdUDPClient1.ReceiveString(12000);
memo1.Text:= temp;
//Bleibt leer
IdUDPClient1.Active:= false;
end;