Solved

TFTP without form

Posted on 1997-05-15
6
272 Views
Last Modified: 2012-05-04
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(Sender: 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.FTPProtocolStateChanged(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('./docserveurNT4.htm','c:\essai.htm');
                    end;
  end;
end;

begin
{******* create the object}
ftpc:=TFTPc.Create(Nil);
{******* attach the procedure to the event}
ftpc.OnProtocolStateChanged := ftpc.FTPprotocolStateChanged;

ftpc.Password:='3il@hol.fr';
ftpc.RemoteHost:='192.9.200.2';
ftpc.RemotePort:=21;
ftpc.UserId:='anonymous';
ftpc.Connect(ftpc.remoteHost,ftpc.RemotePort);
{????????????????   here is the messagebox ?????????????}
MessageDLG('test',mtinformation,[mbOK],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°)
0
Comment
Question by:apostoly
  • 5
6 Comments
 

Expert Comment

by:chrb
ID: 1336284
Hi!

>ftpc:=TFTPc.Create(Nil);
Try this :
 ftpc:=TFTPc.Create(Application);

If it dosn't work try something like this :
 ftpc:=TFTPc.Create([Name of your form]);

Good luck :)

Chr
0
 

Author Comment

by:apostoly
ID: 1336285
not good answer the question is without a Form nor a TApplication
0
 

Expert Comment

by:chrb
ID: 1336286
Sorry,
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Expert Comment

by:chrb
ID: 1336287
Sorry.
0
 

Accepted Solution

by:
chrb earned 0 total points
ID: 1336288
Now I tried it in Delphi, didn't do that last time. But now it works :)

This work fine with me :

program ftpsrv;

uses
 SysUtils,
 Classes,
 Windows,
{ WinSvc,
 NTObj,
 SvcObj,}  { I Havn't client/server}
 DB,
 ISP,Dialogs,
 DBTables,ExtCtrls;

type TFTPc=class(TFTP)
 procedure FTPProtocolStateChanged(Sender: TObject; ProtocolState: Smallint);
end;

var ftpc : TFTPc;
 compteur : integer;
 
{******** this event protocolstatechanged is
never called if i don't put the messagebox you'll see next **************}
procedure TFTPc.FTPProtocolStateChanged(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('/w95files/patch/tray.zip','c:\tray.zip');
 end;
 end;
end;

begin
{******* create the object}
ftpc:=TFTPc.Create(ftpc);
{******* attach the procedure to the event}
ftpc.OnProtocolStateChanged := ftpc.FTPprotocolStateChanged;

ftpc.Password:='lboehn@online.no';
ftpc.RemoteHost:='www.sentralen.com';
ftpc.RemotePort:=21;
ftpc.UserId:='anonymous';
ftpc.Connect(ftpc.remoteHost,ftpc.RemotePort);
{???????????????? here is the messagebox ?????????????}
MessageDLG('test',mtinformation,[mbOK],0);
end.

Hope you get it working now :-)
0
 

Expert Comment

by:chrb
ID: 1336289
Did it works?
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Best Firemonkey component pack 1 104
Delphi selector screen 2 78
Show Listview image from database (String field) 5 124
how to resize animated Gif image in delphi ? 1 31
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question