[twsocket] TFTPClient

Wilfried Mestdagh wilfried_sonal@compuserve.com
Sun, 25 Jun 2000 10:15:50 +0200


Blaster,

Seems ok except for:

-1) You call message pump in OnRequestDone event
(application.processmessges). Dont do it. The event handler can be reentered
by this causing many trouble (eg event stops over there, gets reentered, and
when done the previous one continue -> state is wrong then).

-2) In the OnBgException it seems ok, but I think it is better to set
CanAbort to True. You get a state of ftpReady when the connection is closed
I think, there you can start again.

rgds, Wilfried

> -----Original Message-----
> From: twsocket-admin@elists.org [mailto:twsocket-admin@elists.org]On
> Behalf Of Blaster
> Sent: zondag 25 juni 2000 0:48
> To: twsocket@elists.org
> Subject: Re: [twsocket] TFTPClient
>
>
>
> Hi Wilfried...
>
> I think i'm closing it right? this is what i do:
>
> procedure TfrmMain.FTPBgException(Sender: TObject; E: Exception;
>   var CanClose: Boolean);
> begin
>  LogEvent('Exception Error: '+E.Message);
> //  UpdateIni(Hosts[hID].DataFile, IDENT_LAST_ERROR, DateToStr(Date)+' -
> '+TimeToStr(Time)+': FTP Session timed out');
>  CanClose := False;
>  if FTP.Connected then FTP.QuitAsync else
>   NextFTP;
> end;
>
> --------------------------------------------------------
> this is my requestdone event:
> --------------------------------------------------------
> procedure TfrmMain.FTPRequestDone(Sender: TObject; RqType: TFtpRequest;
>   Error: Word);
> begin
>  Application.ProcessMessages;
>  if Error <> 0 then begin
> //  UpdateIni(Hosts[hID].DataFile, IDENT_LAST_ERROR, DateToStr(Date)+' -
> '+TimeToStr(Time)+': '+FTP.ErrorMessage);
>   UpdateIni(Hosts[hID].DataFile, IDENT_LAST_ERROR, 'This feature has been
> disabled for further use.');
>   FTP.QuitAsync;
>  end else begin
>   case RqType of
>    ftpNone : LogEvent('FTP.RequestDone: None');
>    ftpOpenAsync : begin
>                    LogEvent('Connected to '+Hosts[hID].Alias+', sending
> username..');
>                    UpdateIni(Hosts[hID].DataFile, IDENT_LAST_CONNECT,
> DateToStr(Date)+' - '+TimeToStr(Time));
>                    FTP.UserAsync;
>                   end;
>
>    ftpUserAsync : begin
>                    FTP.PassAsync;
>                   end;
>
>    ftpPassAsync : begin
>                    LogEvent('Logged on to '+Hosts[hID].Alias);
>                    UpdateIni(Hosts[hID].DataFile, IDENT_LAST_LOGON,
> DateToStr(Date)+' - '+TimeToStr(Time));
>                    FTP.QuitAsync;
>                   end;
>    ftpQuitAsync : begin
>                    //Now we are entirly disconnect, connect to next FTP in
> order..
>                    LogEvent('Disconnected from '+Hosts[hID].Alias);
>                    NextFTP;
>                   end;
>   end;
>  end;
> end;
>
>
> Wilfried Mestdagh wrote:
>
> > Blaster,
> >
> > You probably forgot to close the connection if your timeout expires (or
> > forgot to wait until it is closed [requestdone]).
> >
> > rgds, Wilfried
> >
> > > -----Original Message-----
> > > From: twsocket-admin@elists.org [mailto:twsocket-admin@elists.org]On
> > > Behalf Of Blaster
> > > Sent: zaterdag 24 juni 2000 22:24
> > > To: twsocket@elists.org
> > > Subject: [twsocket] TFTPClient
> > >
> > >
> > >
> > > Hi!
> > >
> > > I'm having troubles when using the TFTPClient component in the ICS
> > > Suite.
> > > My application goes through this list of FTPs and checks if they are
> > > valid or not (if they are connectable). If a site is down or does not
> > > responds it automaticly disconnects and tries the next in the
> FTP list..
> > >
> > > I've chained my procs with the OnRequestDone function.
> > >
> > > However, when the app comes to a ftp that does not respond
> and timesout
> > > it doesn't work no more. It looks right (it displays a timeout error
> > > message and tries
> > > the next ftp in order) but all ftps after the one that failed gets the
> > > exact same error.
> > > I then tried to connect to the ftps after the one that failed with a
> > > normal ftp
> > > client and this worked fine.
> > >
> > > At some point the FTP component gives me Exception error
> > > "FTP Component not ready".... (after the the one that failed that is)
> > >
> > > What am I doing wrong?