I am trying to set the connect timeout in the FTPClient. Going by the Javadocs for FTPClient and FTP, it seems that I want to call the setDefaultTimeout(int timeout) just after instanciating a new FTPClient(), but before calling connect(server), shown below.
FTPClient f= new FTPClient(); f.setDefaultTimeout(timeout); f.connect(server); So I tried this out in the examples/ftp.java that came with the commons-net src package. I tried it for a bad non-existent hostname and for a bad non-existent ip address. The bad host name quickly returns in less than 5 seconds. FTPClient f= new FTPClient(); f.setDefaultTimeout(5000); f.connect(bad_hostname); The bad ip address doesn't return in less than 5 seconds and doesn't return in 5 seconds as one would expect. FTPClient f= new FTPClient(); f.setDefaultTimeout(5000); f.connect(bad_ipaddr); It depends which Operating System I am running the example on. When running it on Windows2K i get a consistent timeout on the connect() of about 22seconds, but on RedHat 8 timeout is 128 seconds. I am very confused because I see that alot of the other examples use the setDefaultTimeout() prior to making their connection and they work. Why is setting the DefaultTimeout() prior to connect() not working for the FTPClient? Thanks, Ethan
