Connection reset by peer error - I'm stuck

Giganews Newsgroups
Subject: Connection reset by peer error - I'm stuck
Posted by:  Pete Fraser (pete.fraser@frasersoft.nospam.com)
Date: Mon, 24 Nov 2003

I use the following C++ code to get files from a FTP server.
Sometimes I get a "Connection reset by peer error" which does not get
recovered from even after 10 retries which all fail.

FWIW, I get 10 copies of ThreadException FileName in the event log.

What is the correct way to recover?
Thanks, Pete

  bool Result = true;
  int Retry = 10;
  do
  {
    try
    {
        OutputDebugString(("Get file: "+FileName).c_str());
        FTPClient->Get(RemotePath+"/"+FileName, FileName, true);
    }
    catch(...)
    { // non existant file
        OutputDebugString(("Thread Exception"+FileName).c_str());
        Result = false;  // failed
    }
  }while(!Result && --Retry);  // retry n times

Replies