Connected method shows connection when I don't expect one (Indy 10.0.52)

Giganews Newsgroups
Subject: Connected method shows connection when I don't expect one (Indy 10.0.52)
Posted by:  Mark McLain (mmcla…
Date: Mon, 28 Aug 2006


I recently migrated an old FTP client program that used the NetMasters NMFTP library in Delphi 5 to the TIdFTP class from Indy 10.0.52.  During the migration process, I changed the FTP client code to call the appropriate Indy methods rather than the old NetMaster methods.  This program automatically makes hundreds of ftp connections per day and is responsible for moving files from host-to-host in an enterprise.  Post-migration, the migrated program works fine, most of the time.

My problem is that I am intermittently (< 1% of the time) seeing situations where the "Connected" method reports a connection when I don't expect a connection to be present.  For example, after I am done with a host, I execute the "Quit" method which I understand should be calling the "Disconnect" method.  I then execute the "Connected" method, and it indicates a connection remains.  I then explicitly execute the "Disconnect" method and call the "Connected" method again; it still indicates a connection remains.

I have added some logging code to the "OnDisconnect" event handler and it seems to fire one-time-only, at the time of the first Quit.

One other observation that may be relevant is that, on the same box that the problematic FTP client program is running, there is another Delphi 5 program running an FTP client application that still uses the NMFTP library.  It has not been migrated to Indy.  I have done a "netstat -an" and observed that this second program seems to leave ftp sessions hanging.  For example, this second program can be at a point in its execution where all ftp sessions should be closed, and the "netstat -an" will still show approximately 10 open ftp connections.  I suspect this is a bug in the NMFTP library.

Both the Indy and NMFTP client programs make use of the same ftp site on the server on which they run.

Is it possible that one application is interfering with the other, is there simply a problem with the Indy TIdFTP class, or something else altogether?

Any thoughts are appreciated.  Thanks for your time.