Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi Indy. Könnte das so klappen oder gibt das nur Probleme. (https://www.delphipraxis.net/109482-indy-koennte-das-so-klappen-oder-gibt-das-nur-probleme.html)

Thomas83 2. Mär 2008 13:57


Indy. Könnte das so klappen oder gibt das nur Probleme.
 
hi,

bei meiner Netzwerkanwendung mit indy möchte ich gerne die Kommunikation wie folgt aufbauen.

Client möchte daten vom Server und schickt einen Befehl
Delphi-Quellcode:
Client.WriteLn('GET_KM');
Im Server Execute bekommt er den Befehl und schickt einen neuen Befehl das jetzt die Antwort kommt.
Delphi-Quellcode:
  command := uppercase(AThread.Connection.ReadLn);
  if command = 'GET_KM' then
  begin
    AThread.Connection.WriteLn('A:GET_KM'); //Die Antwort wird gesendet
    AThread.Connection.WriteLn(fClientlist.Text);
  end;
Im Client Execute bekommt er den Befehl.
Delphi-Quellcode:
      command := uppercase(fClient.ReadLn);
      if command = 'A:GET_KM' then
      begin
        s := fClient.ReadLn;
        lbClients.Items.Text := s;
      end;
Wo drauf ich hinaus möchte ist, kommt das auch immer beim Client so an?
Delphi-Quellcode:
    AThread.Connection.WriteLn('A:GET_KM'); //Die Antwort wird gesendet
    AThread.Connection.WriteLn(fClientlist.Text);

Thomas83 2. Mär 2008 15:59

Re: Indy. Könnte das so klappen oder gibt das nur Probleme.
 
hat sich erledigt, habe es anders gelöst.

Larsi 2. Mär 2008 16:09

Re: Indy. Könnte das so klappen oder gibt das nur Probleme.
 
Dann erklär doch mal wie!

Thomas83 2. Mär 2008 16:44

Re: Indy. Könnte das so klappen oder gibt das nur Probleme.
 
mache es simpel mit einer TStringList.
Also

Beim Client
list.add(befehl);
list.add(befehl2);
list.add(daten);
Client.SendText(list.text);
list.free;

Beim Server
list.text := Server.ReadLn;
if list.string[0] = 'Befehl1' then ...
list.string[2]; // Mach was mit Daten


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:46 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz