Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TIdTrivialFTP timing out?

Status
Not open for further replies.

Soniq2

Programmer
Joined
Apr 19, 2010
Messages
2
Location
US
Hi all,

I'm using the TIdTrivialFTP Borland TFTP Class to transfer some data from one machine to another.

I'm using the following code segment:
This works about 50% of the time. However, when it fails, it fails with an exception indicating "No route to host".
Here's the code...

//************************************
TComponent *ftpComponent = new TComponent(NULL);
TIdTrivialFTP* tftpClient;
try
{
tftpClient = new TIdTrivialFTP(ftpComponent);
tftpClient->Host = "10.10.1.10"; // Example Host
Sleep(5000U);
tftpClient->Put("C:\\MyFolder\\MyFile.exe", "File.exe");
delete tftpClient;
delete ftpComponent;
}
catch(EIdTFTPException &)
{
// Retry once
try
{
Sleep(2000U);
tftpClient->Put("C:\\MyFolder\\MyFile.exe", "File.exe");
delete tftpClient;
delete ftpComponent;
}
catch(EIdTFTPException &)
{
delete tftpClient;
delete ftpComponent;
}
}
//**************************************

Does anyone know why this would fail with "No Route To Host"?
Am I using this incorrectly?

Thanks

-Mike
 
I don't think this is the problem but it may streamline you code a bit. Change this:
Code:
  // Retry once
    try
    {
        Sleep(2000U);
        tftpClient->Put("C:\\MyFolder\\MyFile.exe", "File.exe");
        delete tftpClient;
        delete ftpComponent;
    }
    catch(EIdTFTPException &)
    {
        delete tftpClient;
        delete ftpComponent;
    }
to this:
Code:
  // Retry once
    try
    {
        Sleep(2000U);
        tftpClient->Put("C:\\MyFolder\\MyFile.exe", "File.exe");
    }
    finally
    {
        delete tftpClient;
        delete ftpComponent;
    }

This will always clear your client and component.

James P. Cottingham
I'm number 1,229!
I'm number 1,229!
 
Thanks 2ffat for the reply

Yup that's much better for cleanup. :-)

-Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top