Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

TFTP without form

Posted on 1997-05-15
6
Medium Priority
?
284 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

618 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