Arnold FLUTEAUX wrote:
> If I understand well what you say, in may case, when I cut off
> voluntarily the connection from server side, the datasocket must be
> closed and the Connected property must be True. Is that ?
The order in which both connections are closed determines the
server, it may be the other way around, who knows?
> What I don't understand is :
> - if I launch a quitAsync => I've FTP Component not connected.
> And if I laucn connectAsync, I've "Ftp already connected"
> - or if I'm waiting 2 or 3 seconds after cut of the connection,
> Connected property set to false
> In fact, I'm sorry but I don't understand.
>
> So in the case where there is a problem on the line and there is a
> brutal disconnection, what can I test to know if I must launch a
> reconnection without waiting for 2 or 3 seconds ?
Let's play with the FtpTst demo a bit, this code untested and just to
give you an idea what I mean by posting a custom message, I hope it works :)
const
WM_CHECK_CONNECTED = WM_USER + 1;
protected
procedure WmCheckConnected(var Msg: TMessage); message WM_CHECK_CONNECTED;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TFtpReceiveForm.WmCheckConnected(var Msg: TMessage);
begin
if (FtpClient1.State in [ftpReady, ftpInternalReady, ftpPasvReady]) and
(not FtpClient1.Connected) then
//do what you like i.e.
FtpClient1.OpenAsync;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TFtpReceiveForm.FtpClient1RequestDone(Sender: TObject;
RqType: TFtpRequest; Error: Word);
begin
Display('Request ' + IntToStr(Ord(RqType)) + ' Done.');
Display('StatusCode = ' + IntToStr(FtpClient1.StatusCode));
Display('LastResponse was : ''' + FtpClient1.LastResponse + '''');
if Error = 0 then
Display('No error')
else
Display('Error = ' + IntToStr(Error) +
' (' + FtpClient1.ErrorMessage + ')');
{ Display last progress value }
InfoLabel.Caption := IntToStr(FProgressCount);
if Error = 0 then begin
case RqType of
ftpDirAsync, ftpDirectoryAsync,
ftpLsAsync, ftpListAsync : DisplayFile(TEMP_FILE_NAME);
ftpSizeAsync : Display(
'File size is ' +
IntToStr(FtpClient1.SizeResult) +
' bytes' );
ftpPwdAsync, ftpMkdAsync,
ftpCDupAsync, ftpCwdAsync : Display(
'Directory is "' +
FtpClient1.DirResult + '"');
end;
end
// =>
else begin
{ Post a custom message if Get or Put failed. }
{ If the server has closed the control connection }
{ this message should be processed after OnSessionClosed triggered }
case RqType of
ftpGetAsync, ftpPutAsync : PostMessage(Handle, WM_CHECK_CONNECTED,
Ord(RqType), Error);
end;
end;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be