Newsgroups : Borland : borland.public.delphi.internet.winsock : 2005 Jun : TidFtp.List loops forever when Passive = False
| Subject: | TidFtp.List loops forever when Passive = False |
| Posted by: | "Modula" (desenvolvimen..@modula.com.br) |
| Date: | Mon, 13 Jun 2005 13:45:13 |
This is related to problems also mentioned by other users in previous posts,
regarding TidFtp.
I also had some problems with the TidFtp.List method when the Passive =
False. What
happens is that when Passive mode is False, the TidFtp uses the
TidSimpleServer to listen to the server in order to get the files list. When
Passive is True, TidFtp doesn't use the TidSimpleServer. Instead it makes a
new tcp client connection to the server.
When in Passive = False, it creates an instance of TidSimpleServer that
executes the method bellow:
function TIdSimpleServer.Listen: Boolean;
begin
Result := False;
if TIdIOHandlerSocket(IOHandler).TransparentProxy.Enabled then begin
if not FListening then begin
BeginListen;
end;
with Binding do begin
if FAbortedRequested = False then begin
while (FAbortedRequested = False) and (Result = False) do begin
Result :=
TIdIOHandlerSocket(IOHandler).TransparentProxy.Listen(IOHandler,AcceptWait);
end;
end;
end;
end else begin
if not FListening then begin
BeginListen;
end;
with Binding do begin
if FAbortedRequested = False then begin
while (FAbortedRequested = False) and (Result = False) do begin
Result := Readable(AcceptWait);
end;
end;
if Result then begin
Binding.Listen(1);
Binding.Accept(Binding.Handle);
IOHandler.AfterAccept;
end;
// This is now proteced. Disconnect replaces it - but it also calls
shutdown.
// Im not sure we want to call shutdown here? Need to investigate before
fixing
// this.
GStack.Disconnect(FListenHandle);
FListenHandle := Id_INVALID_SOCKET;
end;
end;
end;
Pay attention to the lines:
while (FAbortedRequested = False) and (Result = False) do begin
Result := Readable(AcceptWait);
The result of this behavior is that it will stay in a infinit loop for some
reason there were a problem that made the socket not Readable. The only way
to get out of it is aborting the request using Abort. Course this is not the
correct behaviour, once we specify read and connection timeouts to aware us
of when the expect result have gone out of the expected time.
My app looped through that while forever when I had Passive = False. When I
turned it to True, the problem disapeared and it is working well so far. I'm
using the CesarFtp ftp server, a freeware to test my ftp client.
It took me several hours to figure out this problem but I'm not sure still
on what caused the socket to not be readable. Maybe my server didn't
connected to my client as it expected and stayed there wainting forever.
Maybe it is just the matter of putting a timeout there to work properly (but
right now we can only do it by changing Indy's source).
Hope this is usefull, and would appreciate comments on the issue.
Thiago Linhares de Oliveira