Einzelnen Beitrag anzeigen

Klaus01

Registriert seit: 30. Nov 2005
Ort: München
5.757 Beiträge
 
Delphi 10.4 Sydney
 
#2

Re: TIdTCPServer: OnExecute-Schleife trotz Disconnect

  Alt 4. Sep 2009, 11:58
.. so ganz verstehe ich das nicht.

onExecute und Endlosschleife.

Sollte onExecute ncht ungefähr so gestrickt sein:

(Beispiel aus der Hilfe)
Delphi-Quellcode:
TMyForm.MyServerExecute(AContext: TIdContext);
  var
    lCmd: string;
  begin
    lCmd := Trim(AContext.Connection.IOHandler.ReadLn);
    if AnsiSameText(lCmd, 'HELP') then
    begin
        AContext.Connection.IOHandler.WriteLn('HELP');
        AContext.Connection.IOHandler.WriteLn('QUIT');
        AContext.Connection.IOHandler.WriteLn('GETTIMESTAMP');
        AContext.Connection.IOHandler.WriteLn('');
    end

    else if AnsiSameText(lCmd, 'QUIT') then
    begin
        AContext.Connection.IOHandler.WriteLn('Goodbye...');
        AContext.Connection.IOHandler.WriteLn('');
        AContext.Connection.Disconnect;
    end

    else if AnsiSameText(lCmd, 'GETTIMESTAMP') then
    begin
        AContext.Connection.IOHandler.WriteLn(
          FormatDateTime(Now, 'yyyy-mm-ddThh:nn:ss.zzz'));
        AContext.Connection.IOHandler.WriteLn('');
    end;
  end;
Grüße
Klaus
Klaus
  Mit Zitat antworten Zitat