Thanks Daniel for the response and suggestion for getting this feature into commons-net.
I found aha's(previous list msg) suggested link yesterday and realized that I was going to need J2SE1.4+ in order to develop a Socket connect timeout. Currently my project's J2SE is 1.3.1 so I will have to wait to implement this solution. -Ethan -----Original Message----- From: Daniel F. Savarese [mailto:[EMAIL PROTECTED] Sent: Friday, July 30, 2004 1:19 PM To: 'Jakarta Commons Users List' Subject: Re: [NET] FTPClient - setDefaultTimeout() and setSoTimeout() In message <[EMAIL PROTECTED]>, "Knepp, Ethan" writes: >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. setDefaultTimeout does not set the connect timeout. It provides a default socket timeout. Only in J2SE 1.4 was the ability to specify a timeout on connect added to the Socket API. Since Commons Net 1.2.x has a J2SE 1.2 compatibility requirement, the ability to specify a connect timeout is not included. The way to workaround this is to implement your own SocketFactory and set it with SocketClient.setSocketFactory (FTPClient is a subclass of SocketClient). When you implement the SocketFactory, add a setConnectTimeout method or some such. Inside of the createSocket methods, use the J2SE 1.4 connect method with the timeout. We could actually provide socket factory that subclasses DefaultSocketFactory to do this without breaking backward compatibility, but that would have to be discussed further. The way to do it is to compile it only if J2SE >= 1.4 is being used. SocketClient could check for availability of the J2SE 1.4 connect method and instantiate the J2SE >= 1.4 factory if available (using Class.forName and newInstance). The setDefaultTimeout could then be changed to also set the connect timeout in the new factory if being used. If users want this functionality enough, the best chance of getting it implemented soon is to submit a patch. daniel --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
