I have an application which FTP's a small file to multiple IP's when it runs into locations that it can't connect to it should just kick out stating that it couldn't connect (which it did most of the time). Now when I go to run the program it will run though the list of IP's and hang about half way though. It will hang on the connect, login or chdir commands (it will vary time to time). It doesn't seem to want to timeout or throw an exception. I want it to just skip the IP if is having poblems connecting to it and let me know by timing out or throwing an exception.
Any Ideas?
Here is the code I have:
public class FtpProc {
public FtpProc() {
}
public String FtpRun(String loc, String userid, String pwd, String FileNm) {
String Error;
FTPClient ftp = null;
try {
// set up client
ftp = new FTPClient();
ftp.setRemoteHost(loc);
FTPMessageCollector listener = new FTPMessageCollector();
ftp.setMessageListener(listener);
// connect
ftp.connect();
ftp.login(userid, pwd);
ftp.chdir("//loc/path");
ftp.put(FileNm, FileNm);
ftp.quit();
}
catch (Exception e) {
Error = " - Exception message: " + e.getMessage();
return Error;
}
return "";
}
}