Autor Beitrag
Harry M.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: Do 28.04.05 12:57 
Mahlzeit...

Ich möchte einen TCPClienten für eine Konsolen-Applikation zur Laufzeit erstellen. Bisher habe ich folgenden Code:

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:
40:
41:
42:
43:
44:
45:
46:
47:
48:
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  IdTCPClient;

type
  TTCPClient = class
  private
    { Private declarations }
    TCPClient: TIdTCPClient;

    { Public declarations }
  public
    Constructor Create; Reintroduce;
    Destructor Destroy; Override;
  end;

////////////////////////////////////////////////////////////////////////////////
Constructor TTCPClient.Create;
begin
  TCPClient.Create(nil);
  TCPClient.Host := '192.168.0.11';
  TCPClient.Port := 22544;
end;
////////////////////////////////////////////////////////////////////////////////
Destructor TTCPClient.Destroy;
begin
  TCPClient.Free;
  Inherited Destroy;
end;
////////////////////////////////////////////////////////////////////////////////

{ ----------------------------- Hauptprogramm -------------------------------- }
begin
  with TTCPClient.Create do begin
    try
    TCPClient.Connect(-1);
    except; end;
    if TCPClient.Connected then writeln('TCPClient verbinden')else writeln('TCPClient konnte nicht verbinden');
    TCPClient.Disconnect;
    end;

  readln;
{ ------------------------- Ende des Hauptprogramms -------------------------- }
end.


Ich kann das Projekt zwar compilieren, aber das Programm beendet sofort wieder. Beim setzten von Haltepunkten ist mir aufgefallen, das das Programm immer im Constructor bei TCPClient.Create(nil); die weitere Ausführung abbricht. Keine Exception, keine Fehlermeldung nichts. Was habe ich falsch gemacht??

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Do 28.04.05 13:09 
Es fehlen einige Units, die normalerweise beim auf-die-form-ziehen eingefügt werden:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
uses IdBaseComponent,
  IdComponent,
  IdTCPConnection,
  IdTCPClient,
  IdFTP;

Dann sollte es klappen.

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
huhn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 272
Erhaltene Danke: 1

WIN XP
D7Pers
BeitragVerfasst: Do 28.04.05 13:12 
mmh las mal des weg
ausblenden Delphi-Quelltext
1:
TCPClient.Create(nil);					

glaube das des schon bei connect mit drinne is!
und dann
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
begin  
  with TTCPClient.Create do begin  
    try  
    TCPClient.Connect(-1);  //is doch timeout oder?naja lass des einfach mal weg!
    //TCPClient.connect;
    except; end;  
    if TCPClient.Connected then writeln('TCPClient verbinden')else writeln('TCPClient konnte nicht verbinden');  
    TCPClient.Disconnect;  
    end;

ach und es fehlen noch ein paar untis glaub i!
//edit: die hier "IdBaseComponent, IdComponent, IdTCPConnection"
//edit2:ach jetz versteh ich was du machen wolltest
mfg huhn

_________________
Quod Erat Demonstrandum-Was zu beweisen war! *THX to Chrissivo!*
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Do 28.04.05 13:20 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var
   FTPClient:TidFTPclient;
begin
FTPClient:=TidFTPClient.Create(nil);
{...}

Nun? was hab ich gesagt? xD

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.


Zuletzt bearbeitet von JayEff am Do 28.04.05 21:54, insgesamt 1-mal bearbeitet
Harry M. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: Do 28.04.05 13:21 
Die vermeintlich fehlenden Units (IdBaseComponent, IdComponent, IdTCPConnection) hatte ich bereits in die Uses-Klause geschrieben. Brachte aber auch nicht den gewünschten Erfolg.

@JayEff auch diese Möglichkeit hatte ich schon durchprobiert. Das Result....

Ich habe versucht mich anhand des FTP-Server-Demos (Indy 9) zuorientieren.

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.
huhn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 272
Erhaltene Danke: 1

WIN XP
D7Pers
BeitragVerfasst: Do 28.04.05 13:31 
irgendetwas beist sich bei deinem ding da in den schwanz!nimm mal andere namen, da kommt man ganz durcheinander!
mfg huhn

_________________
Quod Erat Demonstrandum-Was zu beweisen war! *THX to Chrissivo!*
Harry M. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: Do 28.04.05 13:35 
Ich habe die DRP mal schnell hochgeladen. So können alle es besser Testen.

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.
DataCool
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Do 28.04.05 17:12 
Hi,

wie wärs wenn Du Dir mal den Constructor Deiner KLasse genau anschaust ;-)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
Constructor TTCPClient.Create;
begin
  TCPClient.Create(nil);
  TCPClient.Host := '192.168.0.11';
  TCPClient.Port := 22544;
end;


richtig wäre :

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
Constructor TTCPClient.Create;
begin
  TCPClient := TIdTCPClient.Create(nil);
  TCPClient.Host := '192.168.0.11';
  TCPClient.Port := 22544;
end;


Gruß Data

Moderiert von user profile iconKlabautermann: Code- durch Delphi-Tags ersetzt.

_________________
DataCool
Harry M. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: Do 28.04.05 18:20 
Jo naklar, jetzt wo ich es sehe... das hätte ich eigendlich auch sehen müssen :eyecrazy:
Manchmal sieht man eben den Wald vor Bäumen nicht.
Danke.

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.