Re: IOHandler nil after connect exception

Giganews Newsgroups
Subject: Re: IOHandler nil after connect exception
Posted by:  Remy Lebeau (TeamB) (
Date: Fri, 14 Oct 2005

"Pierre Axelsson" <> wrote in message

> If I connect to a server that doesn't exist an EIdSocketError exception
> is raised. This is OK,  but when I catch the exception the IOHandler
> property has become nil.

If you do not assign your own IOHandler, then TIdTCPClient creates its own
internally when Connect() is called.  When Connect() throws an exception,
the IOHandler is automatically freed if Connect() created it.

> In my app I use a TIdLogFile to log all FTP traffic. Everything works
> fine to the point where this happens (a host is down or non-existing) and
> when it does, the traffic logging is broken for all future FTP-sessions.

I find that highly unlikely.

TIdFTP overrides Connect() in order to handle additional FTP-related
negotiations after TIdTCPClient.Connect() succeeds in establishing the
underlying connection.  If TIdTCPClient.Connect() throws an exception, then
TIdFTP calls Disconnect().  Disconnect() closes, but does not remove or
destroy, the IOHandler.  In order to log TIdFTP.Connect()'s activities, you
must assign your own IOHandler instance before calling Connect().  Indy
never removes or frees a user-specified IOHandler.  TIdIOHandlerStack is the
default IOHandler class that Connect() creates when needed, and it is a
component that can be dropped onto a form alongside TIdFTP like any other



In response to

IOHandler nil after connect exception posted by Pierre Axelsson on Fri, 14 Oct 2005