?
Solved

TFTP without form

Posted on 1997-05-15
6
Medium Priority
?
280 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month11 days, 14 hours left to enroll

752 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