Exported from Bugzilla, issue 3372.
--- Comment added on 6/19/02 8:35:15 AM ---
Jim North, 6/17/2002
I am having trouble doing a multiple-file transfer during a single login
session.
Basically my Status handler is as follows and related code is below.
The first file transfers okay, but additional transfers hang up after the
"200 Type set to A" reply. The problem is timing-related because
sometimes the hang-up is on the second file, and other times two or
three are transferred before it hangs.
Is there some timing issue that my code is not handling?
Jim
Polaris Microsystems
========== Code follows ===========
procedure Tfrm.IpFtpClient1FtpStatus(Sender: TObject;
StatusCode: TIpFtpStatusCode; const Info: String);
var
i,p: integer;
begin
case StatusCode of
fscLogin:
begin
case fUpdateState of
usGetDir:
if not IpFtpClient1.ListDir(cfLOG_PATH,false) then
begin
ErrorMsg('Unable to read directory.');
fUpdateState:= usIdle;
end;
end;
end;
fscDirList:
begin
case fUpdateState of
usGetDir:
begin
fLogFileIndex:= 0; // pointer to file name list
fLogFileList.Text:= info;
for i:= 0 to fLogFileList.Count-1 do
begin // strip path from names
p:= pos('//',fLogFileList.Strings[i]);
if p>0 then
fLogFileList.Strings[i]:=
copy(fLogFileList.Strings[i],p+2,
length(fLogFileList.Strings[i]));
end;
if FLogFileList.Count>0 then
GetNextLogFile
else
begin
fUpdateState:= usIdle;
IpFtpClient1.Logout;
end;
end;
end;
end;
fscTransferOK:
begin
if fLogFileIndex<fLogFileList.Count-1 then
begin
inc(fLogFileIndex);
GetNextLogFile;
end
else
begin
fUpdateState:= usIdle;
IpFtpClient1.Logout;
end;
end;
end;
end;
procedure Tfrm.GetNextLogFile;
var
fName: string;
begin
fUpdateState:= usDownloading;
fName:= fLogFileList.Strings[fLogFileIndex];
if not
IpFtpClient1.Retrieve(cfLOG_PATH+'/'+fName,HomeDir+clLogDir+fName,rmReplace,
0 ) then
begin
fUpdateState:= usIdle;
end;
end;
--- Comment added on 6/19/02 8:36:10 AM ---
Jim North, 6/18/2002
From what I can see, the fscTransferOk status is triggered before
the 226 Reply (Transfer Complete) is received. Consequently, the
next Retrieve call is being sent too soon and the session hangs.
--- Comment added on 6/19/02 8:36:34 AM ---
Jim North, 6/19/2002
Sean,
I already tried adding ProcessMessages calls, and it is not reliable.
It does help (because it adds a delay), but it is not 100%. What I am
doing for now is using the Reply handler to test for ReplyCode 226
after each call to Retrieve. This seems to work, although there are
sometimes some "long" (2 or 3 seconds) waiting for the reply.
I don't know if this is how things are supposed to work -- being only
marginally informed on FTP.
Jim