okay, der code hier is vielleicht net gerade der beste, sollte aber funktionieren (
indy 10):
Delphi-Quellcode:
uses ..., IdContext, ...
procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
var eCommand:String;
eList:TStringList;
begin
repeat
try
eCommand := AContext.Connection.Socket.ReadLn;
eCommand := UpperCase(eCommand);
if eCommand = 'UPDATE' then begin
eList := TStringList.Create;
eList.Text := ComponentToString(Self); //hier dann z.b. ListView1
AContext.Connection.Socket.Write(eList, True);
eList.Free;
end;
except
//mach was beim fehler
end;
until (Application.Terminated) or (not AContext.Connection.Connected);
end;
procedure TForm1.IdTCPClient1Connected(Sender: TObject);
var eList:TStringList;
begin
IdTCPClient1.Socket.WriteLn('UPDATE');
eList := TStringList.Create;
IdTCPClient1.Socket.ReadStrings(eList);
showmessage(eList.Text);
eList.Free;
end;
btw würde ich ReadLn etc. in
threads auslagern...