Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi TIdTCPServer.OnExecute := ???; (https://www.delphipraxis.net/77378-tidtcpserver-onexecute-%3D-%3B.html)

Snoke 18. Sep 2006 23:16


TIdTCPServer.OnExecute := ???;
 
hi

erstmal der code:

Delphi-Quellcode:
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils, IdTCPServer;

type
  TTCPServer = class
  private
    IdTCPServer: TIdTCPServer;
    procedure IdTCPServerOnExecute;
  public
    constructor Create; reintroduce;
  end;

var
  mread: String;

constructor TTCPServer.Create;
begin
  IdTCPServer := TIdTCPServer.Create(nil);
  IdTCPServer.DefaultPort := 3724;
  IdTCPServer.MaxConnections := 100;
  IdTCPServer.OnExecute := IdTCPServerOnExecute;
  IdTCPServer.Active := True;
end;

begin
  with TTCPServer.Create do
  try
    writeln( 'running, press [enter] to terminate' ) ;
    readln(mread);
  finally
    free;
  end;
end.
fehler:
[Pascal Error] Project1.dpr(25): E2009 Incompatible types: 'Parameter lists differ'
[Pascal Error] Project1.dpr(12): E2065 Unsatisfied forward or external declaration: 'TTCPServer.IdTCPServerOnExecute'

problem: ich verstehe dieses OnExecute nicht, laut hilfe ist das ne properity so wie ich gelesen habe, allerdings finde ich im inet beispiele wo das ein event ist (was ich auch denke). wie gehe ich mit OnExecute und den restlichen Events um?

TKC 18. Sep 2006 23:24

Re: TIdTCPServer.OnExecute := ???;
 
wo ist denn deine Procedure TTCPServer.IdTCPServerOnExecute ???

mkinzler 19. Sep 2006 07:38

Re: TIdTCPServer.OnExecute := ???;
 
Was steht in Zeile 25?

s.h.a.r.k 19. Sep 2006 08:46

Re: TIdTCPServer.OnExecute := ???;
 
Hey, also ich würde das ganze vielleicht mal so anfangen - gehe jetzt einfach mal davon aus, dass du auch Indy 10 verwendest ;)

Delphi-Quellcode:
program Project1;

{$APPTYPE CONSOLE} 

uses
  SysUtils, IdTCPServer, IdSocketHandle, IdContext; // Zwei weitere Units nötig!

type
  TTCPServer = class
  private
    IdTCPServer: TIdTCPServer;
    procedure IdTCPServerOnExecute(AContext: TIdContext);
  public
    constructor Create; reintroduce;
  end;

var
  mread: String;

procedure TTCPServer.IdTCPServerOnExecute(AContext: TIdContext);
begin
 
  // HIER KOMMT DEIN CODE BEI EINER ABFRAGE VOM CLIENT


  // Diese Zeile bitte belassen - gegen 100% CPU-Auslastung
  SleepEx(1, True);
end

constructor TTCPServer.Create;
var
  NewBinding : TIdSocketHandle
begin
  IdTCPServer := TIdTCPServer.Create(nil);
  IdTCPServer.DefaultPort := 3724;
  IdTCPServer.MaxConnections := 100;
  IdTCPServer.OnExecute := IdTCPServerOnExecute;
  NewBinding := IdTCPServer.Bindnig.Add;
  NewBinding.IP := '127.0.0.1'; // solltest noch ändern
  NewBinding.Port := 3724;     // sollte passen
  IdTCPServer.Active := True;
end;

begin
  with TTCPServer.Create do
  try
    writeln( 'running, press [enter] to terminate' ) ;   readln(mread);
  finally
    free;
  end;
end.

Snoke 19. Sep 2006 18:10

Re: TIdTCPServer.OnExecute := ???;
 
vielen dank s.h.a.r.k funzt gut :)

nur eine kleinigkeit: OnExecute wird dauernd ausgeführt, zwar wird durch des SleepEx die cpu last verringert, aber bei vielen usern wird das doch sehr performance lastig? wieso wirds dauernd ausgeführt? ich dachte OnExecute reagiert nur wenn ein paket reinkommt?


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:40 Uhr.

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