barrois
asked on
TFTP without Form
I encounter problems with the TFTP component:
I'm working under delphi 2.0 Client/Server, writing a console application
using the TFTP component (as an object created in the application).
Since now I never managed to even connect to my FTP server,
but by hazard, I saw that puting a messagebox call at the end of my code make
it work perfectly. I try to replace it by a sleep and so on, no one made it.
Here is my code :
program ftpsrv;
uses
SysUtils,
Classes,
Windows,
WinSvc,
NTObj,
SvcObj,
DB,
ISP,Dialogs,
DBTables,ExtCtrls;
type TFTPc=class(TFTP)
procedure FTPProtocolStateChanged(Se nder: TObject; ProtocolState: Smallint);
end;
{$R *.RES}
var ftpc : TFTPc;
compteur : integer;
{******** this event protocolstatechanged is
never called if i don't put the messagebox you'll see next **************}
procedure TFTPc.FTPProtocolStateChan ged(Sender : TObject; ProtocolState: Smallint);
begin
case ProtocolState of
ftpBase : ftpc.Free;
ftpAuthentication: Authenticate(UserId, Password);
ftpTransaction: begin
{****** when connected I get a file to see if it works}
ftpc.GetFile('./docserveur NT4.htm',' c:\essai.h tm');
end;
end;
end;
begin
{******* create the object}
ftpc:=TFTPc.Create(Nil);
{******* attach the procedure to the event}
ftpc.OnProtocolStateChange d := ftpc.FTPprotocolStateChang ed;
ftpc.Password:='3il@hol.fr ';
ftpc.RemoteHost:='192.9.20 0.2';
ftpc.RemotePort:=21;
ftpc.UserId:='anonymous';
ftpc.Connect(ftpc.remoteHo st,ftpc.Re motePort);
{???????????????? here is the messagebox ?????????????}
MessageDLG('test',mtinform ation,[mbO K],0);
{???????????????? if i don't put this, my file isn't downloaded, just because the
FTP client never connects. the event protocolstatechanged is never called
Please help me !!!!! 8°)
I'm working under delphi 2.0 Client/Server, writing a console application
using the TFTP component (as an object created in the application).
Since now I never managed to even connect to my FTP server,
but by hazard, I saw that puting a messagebox call at the end of my code make
it work perfectly. I try to replace it by a sleep and so on, no one made it.
Here is my code :
program ftpsrv;
uses
SysUtils,
Classes,
Windows,
WinSvc,
NTObj,
SvcObj,
DB,
ISP,Dialogs,
DBTables,ExtCtrls;
type TFTPc=class(TFTP)
procedure FTPProtocolStateChanged(Se
end;
{$R *.RES}
var ftpc : TFTPc;
compteur : integer;
{******** this event protocolstatechanged is
never called if i don't put the messagebox you'll see next **************}
procedure TFTPc.FTPProtocolStateChan
begin
case ProtocolState of
ftpBase : ftpc.Free;
ftpAuthentication: Authenticate(UserId, Password);
ftpTransaction: begin
{****** when connected I get a file to see if it works}
ftpc.GetFile('./docserveur
end;
end;
end;
begin
{******* create the object}
ftpc:=TFTPc.Create(Nil);
{******* attach the procedure to the event}
ftpc.OnProtocolStateChange
ftpc.Password:='3il@hol.fr
ftpc.RemoteHost:='192.9.20
ftpc.RemotePort:=21;
ftpc.UserId:='anonymous';
ftpc.Connect(ftpc.remoteHo
{???????????????? here is the messagebox ?????????????}
MessageDLG('test',mtinform
{???????????????? if i don't put this, my file isn't downloaded, just because the
FTP client never connects. the event protocolstatechanged is never called
Please help me !!!!! 8°)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER