Re: FTP on unstable connection

Giganews Newsgroups
Subject: Re: FTP on unstable connection
Posted by:  Remy Lebeau \(Indy Team\) (re…@lebeausoftware.org)
Date: Wed, 30 Mar 2011

"Christian Kaufmann" <christian.kaufma…@gmx.net> wrote in message
news:nht5p61gbgcj1h1il1p6n32jjaq9iogp…@4ax.com...

> I would like to correct my code that way, that the thread
> does not fail, but just tries again when it is executed for
> the next time.

Simply place your EnsureUploadFile() logic inside a loop, and then exit the
loop when TIdFTP.Put() is successful, eg:

procedure TLiveResult.EnsureUploadFile(const AFile: String);
var
  err : String;
  tmp : String;
begin
  if [ AFile doesn't need upload ]
    then Exit;

  repeat
    try
      if not FFtpClient.Connected then
      begin
        FFtpClient.Connect;
        FFtpClient.RemoteChangeDir(FRemoteDirectory);
      end;
      FFtpClient.Put(AFile, AFile, False);
      Exit;
    except
      FFtpClient.Disconnect(False);
      if Assigned(FFtpClient.IOHandler) then
        FFtpClient.IOHandler.InputBuffer.Clear;
      Sleep(1000);
    end;
  until False;
end;

--
Remy Lebeau (Indy Team)

Replies

None

In response to

FTP on unstable connection posted by Christian Kaufmann on Wed, 30 Mar 2011