Autor Beitrag
nabbl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 51

Win XP Home
Delphi 7 PE
BeitragVerfasst: Fr 18.08.06 23:34 
Hi! Habe mal wieder ne Frage: Wie kann ich bei ner konsolen-app. und der indy-tcp-server das Ereignis OnExecute initialiseren und nutzen?

Mein Quelltext bisher:
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:
program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  IdTCPServer;

procedure TCPServerExecute(AThread: TIdPeerThread);
begin
  with AThread.Connection do
  begin
    WriteLn('Hello from Basic Indy Server server.');
    Disconnect;
  end;
end;

var TCPServer : TIdTCPServer;
begin

 TCPServer := TIdTCPServer.create(nil);
 TCPServer.DefaultPort := 8888;
 TCPServer.Active := True;

end.


Wie bekomme ich nun aber "TCPServerExecute" zum laufen?

Danke für die Hilfe
Nabbl.
nabbl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 51

Win XP Home
Delphi 7 PE
BeitragVerfasst: Sa 19.08.06 18:11 
Ich weiß zwar, dass ich eigtl. warten müsste, aber ich hoffe, dass ich so auf eine Lösung kommen könnte:

Ist meine Frage zu undeutlich formuliert? Oder wisst ihr keine Antwort?

MfG Nabbl
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: So 20.08.06 00:11 
Moin!

Das wird mit den Ereignissen in einer Konsolenapp auch nicht klappen, weil die keine MessageLoop hat.

Mach einfach eine Fenster-Applikation draus, dann geht´s (das TApplication-Objekt ist der Schlüssel).

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
nabbl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 51

Win XP Home
Delphi 7 PE
BeitragVerfasst: So 20.08.06 00:34 
user profile iconNarses hat folgendes geschrieben:
Moin!

Das wird mit den Ereignissen in einer Konsolenapp auch nicht klappen, weil die keine MessageLoop hat.

Mach einfach eine Fenster-Applikation draus, dann geht´s (das TApplication-Objekt ist der Schlüssel).

cu
Narses


*grml* wollte das Tool mit CrossKylix für meinen Linux-Server zum laufen bekommen....
nabbl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 51

Win XP Home
Delphi 7 PE
BeitragVerfasst: So 20.08.06 22:15 
Also gibt es keine Möglichkeit?
nabbl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 51

Win XP Home
Delphi 7 PE
BeitragVerfasst: Di 22.08.06 23:42 
habe ne lösung gefunden:
ausblenden volle Höhe 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:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
program Project2;

{$APPTYPE CONSOLE}

uses idTCPServer, idGlobal;

procedure TCPSExecute(Sender: TObject; AThread: TIdPeerThread);
var msg : string;
begin
  With AThread do
  begin
    While Connection.Connected do
    begin
    msg := Connection.ReadLn;
    writeln(msg);
     begin
      WriteLn('Connected: ');
      Connection.WriteLn('Erfolgreich eingeloggt!: '+Connection.);

     end;
    end;
  end;
Sleep(200);
end;

var TCPS:TidTCPServer;
M: TMethod;
begin
  TCPS:=TidTCPServer.Create(nil);
  TCPS.DefaultPort:=8008;
  TCPS.Active:=True;
  M.Code := @TCPSExecute;
  M.Data := @TCPS;
  TCPS.OnExecute := TIdServerThreadEvent(M);
  While true do
  begin
    Sleep(10);
  end;
end.