'Reset' FTP Client

Giganews Newsgroups
Subject: 'Reset' FTP Client
Posted by:  Pierre Roux (pier…@infofx.co.za)
Date: Mon, 15 Nov 2004

Hi,

I'm uploading a file to a server every X amount of time.  There is no
problems as long as every upload is successful, however, if it fails once,
the applications needs to be restarted, otherwise it always fails
thereafter.  Restarting the server has no effect.

The error varies - Could not Connect / Connection Reset by Peer

I'm working with Delphi 7 and an Indy10 Snapshot about a week old.

Code:
  try
  while not FTP.Connected and (iCount > 0) do
    begin
    try
    FTP.Connect;
    except
    Log(3,'FTP Connection to ' +FTP.Host+ ' failed.');
    Dec (iCount);
    end;
    end;

  if FTP.Connected ) then
    begin
    Log(0,'FTP Connected to '+ FTP.Host);

    for iCount := 0 to lsSettings.Count - 1 do
        begin
        sSource        :=
ExtractFileDir(Application.ExeName)+'\output\'+lsDecode.Strings[1];
        sDestination  := lsDecode.Strings[0];

        if FileExists(sSource) then
          begin
          try
          FTP.Put (sSource, sDestination);
          except
          On E: Exception do
              begin
              Log(3,'FTP Error:'+E.Message);
              end;
          end;

          end;
        end;

        if FTP.Connected ) then
            FTP.Disconnect;

    end;

PS:  During debugging, any application that contains either an TIdHTTP or
TIdFTP componant takes ages to close if either of those componant were used
(i.e. connected) during a debugging session.  This behaviour does not take
place when running the application outside the IDE.

Replies