IdFtp9->Connect() hangs

Giganews Newsgroups
Subject: IdFtp9->Connect() hangs
Posted by:  poojo hackma (
Date: Thu, 8 Jun 2006

My Indy 9 TIdFtp component will hang in BCB6 if a connection can not be
found.  I have set a 2 second timeout, but this does not seem to effect the
Connect() method.

Am I doing something wrong?  Is there a better way of doing this?

Here's how my code is set up (with irrelevant code deleted):

  mFtp = new TIdFTP(NULL);
  mFtp->Host    = AnsiString(FTP_HOST1) + AnsiString(FTP_HOST2);
  mFtp->Username = AnsiString(FTP_USERNAME1) + AnsiString(FTP_USERNAME2);
  mFtp->Password = AnsiString(FTP_PASSWORD1) + AnsiString(FTP_PASSWORD2);
  mFtp->OnStatus = FtpStatus;
  mFtp->OnWork      = FtpWork;
  mFtp->OnWorkBegin = FtpWorkBegin;
  mFtp->OnWorkEnd  = FtpWorkEnd;
  mFtp->OnAfterGet  = FtpAfterGet;
  mFtp->ReadTimeout = 2000;          // timeout after 2 seconds
  {    // includes a __finally for mFtp->Quit();
    {  // includes a catch()
      if (mFtp->Connected() == false)
        MessageLog("Unable to connect to Update Server.");
        // proceed to download my files and such.
    catch (const EIdSilentException &eId)
      /*  A little about Indy Exceptions (copied from their help pages):
      "[The Exception] EIdConnClosedGracefully for servers is trapped and
      While EIdConnClosedGracefully can be an error it is often a "normal"
      condition. Because of this, it descends from EIdSilentException. You
      add EIdSilentException to your debugger options to tell the debugger
not to
      stop on these exceptions. The exception will still occur and your EXE
      still function the same, however the debugger just wont stop on them
    catch (const Exception &ex)
  }  // end of first try block
      mFtp->Abort(); // if a file transfer is in progress
      mFtp->Quit();  // closes the connection
      ::Sleep(1000); // control will still send a few messages back to mFtp
      delete mFtp;
      mFtp = NULL;