Without having a way to model the timeouts you see, it's going to be hard to give
accurate advice to fix your problems, but I can give some general advice.
* When you create your ftp object, make sure you set Debug = 1. There is also a Timeout flag you can turn on.
my $ftp = Net::FTP->new("foo.bar.com", Debug => 1, Timeout => 120);
* A lot of people here don't like the CGI101 pages but their
Net::FTP page is pretty good.
* When I tested timeout code on servers that don't have an ftp server, the error I would get is:
Can't call method "login" on an undefined value at ./ftp_timeout_test.pl line XX. And of course the code wouldn't continue because the module failed. But one possible work around would be something like:
* Set a timeout for, oh 300 seconds when you instantiate the Net::FTP object but then
set an alarm for 295 seconds just prior to that. Trap the alarm signal to give you a timeout. If the connection proceeds smoothly, then unset the alarm.