Autor Beitrag
Sithlord
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 172



BeitragVerfasst: Mi 19.05.10 01:38 
Hallo Mitglieder,

ich benutze die idUDP Komponente und gebe für meinen Server IP und Port an, klappt per PHP auch einwandfrei. Dort mache ich es nach dem folgenden Prinzip und sende folgenden String an den Server:"rcon PASS BEFEHL".
Nur per Delphi klappt dies nicht. Weiß irgendeiner warum? Zur Hilfe mal den PHP Quellcode, damit vl. jemand weiß, warum ich in Delphi nicht einfach so einen String dahin senden kann.
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
  class  rconstring_query {
  
          private $rconpassword;
          private $fp;
          private $cmd;
          private $lastcmd;
  
          public function __construct($address, $port) {
                  $this->cmd = str_repeat(chr(255), 4);
                $this->fp = fsockopen("udp://$address", $port, $errno, $errstr, 10);
                  if (!$this->fp){
            die("$errstr ($errno)\n");
          }
          }
      
          public function close() {
        fclose($this->fp);
      }
          public function set_rconpassword($p) {                  
          $this->rconpassword = $p;
          }
  
          public function rcon($s) {
                  sleep(1);
                  $this->send('rcon '.$this->rconpassword.' '.$s);
          }
          public function sendit($s) {
                 // sleep(1);
                  $this->send($s);
          }
  
          public function get_response($timeout=5) {
                  $s = '';
                  $bang = time() + $timeout;
                  while (!strlen($s) and time() < $bang) {
                          $s = $this->recv();
                  }
                  if (substr($s, 0, 4) != $this->cmd) {
                  }
                  return substr($s, 4).$delimiter;
        }
  
          private function send($string) {
                  fwrite($this->fp, $this->cmd . $string . "\n");
          }
  
          private function recv() {
                  return fread($this->fp, 9999).$delimiter;
          }
  
  }


Wie gesagt, per PHP geht es, aber nicht per Delphi indem ich einfach den String "rcon PASS BEFEHL" rübersende ...
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Mi 19.05.10 12:39 
Und wie sieht der Delphi Code aus, mit dem es nicht funktioniert?

_________________
PROGRAMMER: A device for converting coffee into software.
Sithlord Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 172



BeitragVerfasst: Mi 19.05.10 13:27 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
idudp.Active:=true;
idudp.Host:='host';
idudp.Port:=0;
idudp.Send('rcon MeinPasswort say "Testnachricht"');
idudp.Active:=false;


Deshalb meinte ich ich sende nur kurz was hin, kein komplizierter Quellcode, aber am Server kommt nichts an, per PHP, die Sprache die ich besser beherrsche, hingegen schon.
ALF
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1085
Erhaltene Danke: 53

WinXP, Win7, Win10
Delphi 7 Enterprise, XE
BeitragVerfasst: Mi 19.05.10 14:10 
Hi, Bist Du sicher das es der Port 0 ist?
Was machst Du hier 'host', ist das ne Variable oder was ist das?
und hier? ('rcon MeinPasswort say "Testnachricht"')
Steht dort ne Variable oder Dein original Passwort?
Gruss Alf

_________________
Wenn jeder alles kann oder wüsste und keiner hätt' ne Frage mehr, omg, währe dieses Forum leer!
Sithlord Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 172



BeitragVerfasst: Mi 19.05.10 14:30 
Nein ich habe lediglich die Daten verfremdet, da der Server ja nicht gleich im Netz bekannt sein muss ;)
Meinpasswort ersetze ich durch mein RCON Passwort.
Niko S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 566
Erhaltene Danke: 10

Win 7, Ubuntu
Lazarus, Turbo Delphi, Delphu 7 PE
BeitragVerfasst: Mi 19.05.10 16:49 
Vielleicht solltest du erst, Port und IP eintragen und dann IdUDP.connect oder IDUDP.open machen.
Sithlord Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 172



BeitragVerfasst: Mi 19.05.10 17:53 
Danke sehr, aber hat leider auch nichts gebracht, der Server macht keinen Mucks etwas auszugeben ...
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Mi 19.05.10 22:46 
Hast du mal nen Wireshark angeworfen, ob wirklich die richtigen Daten rausgehen?

_________________
PROGRAMMER: A device for converting coffee into software.
ALF
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1085
Erhaltene Danke: 53

WinXP, Win7, Win10
Delphi 7 Enterprise, XE
BeitragVerfasst: Sa 22.05.10 13:02 
Hi, ich schieb den noch mal hoch :wink:
Hier mal der richtige Ansatz auf einem linux/ETGamesserver, geschrieben mit Delphi7Enterprise und Indy10.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
procedure TForm1.Button1Click(Sender: TObject);
begin
   idudpclient1.Active := false;
   idudpclient1.Host := 'oldman.servegame.org';
   idudpclient1.Port := 27960;
   idudpclient1.Active := true;

   idudpclient1.Send(chr(255)+chr(255)+chr(255)+chr(255)+'getstatus');
   stringreturn := idudpclient1.ReceiveString();
   memo1.Lines.add(inttostr(length(stringreturn))+' bytes');
   memo1.lines.add(stringreturn);
   memo1.Lines.add('');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
  idudpclient1.Active := false;
  idudpclient1.Host := 'oldman.servegame.org';
  idudpclient1.Port := 27960;
  idudpclient1.Active := true;
  
  idudpclient1.Send(chr(255)+chr(255)+chr(255)+chr(255)+'rcon "rconpass" ' + 'say "hallo_leute"');
  stringreturn := idudpclient1.ReceiveString();
  memo1.Lines.add(inttostr(length(stringreturn))+' bytes');
  memo1.lines.add(stringreturn);
  memo1.Lines.add('');
end;


Gruss Alf

_________________
Wenn jeder alles kann oder wüsste und keiner hätt' ne Frage mehr, omg, währe dieses Forum leer!
Sithlord Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 172



BeitragVerfasst: Mo 11.07.11 19:44 
Nachdem ich mich leider lange nicht gemeldet habe, Danke, so hat das geklappt :)

_________________
Heut ist nicht alle Tage, ich hab wieder ein Problem, keine Frage...