|
[
Permlink
| « Hide
]
Christian Hufgard added a comment - 25/Sep/06 10:17 AM
Simple factory that uses jdk1.4's feature to create a Socket with a connection timeout.
This is not a bug. You used the API exactly as intended. If you want a connect timeout, you need to create a socket factory (this has been explained multiple times on th mailing list). Commons Net 1.4.1 is JDK 1.3 compatible. Therefore, it cannot support connect timeouts. setDefaultTimeout does exactly what it is supposed to do. It sets the socket timeout (read/write timeout). For a release that supports JDK 1.4 or 1.5 as a baseline, connect timeouts will be added.
Thanks for the quick response.
Ok, should have checked the archives before Maybe SocketClient.setDefaultTimeout(int timeout) would be a good place to get this information noticed. I still think, this behaviour is a little bit strange. We also use commons-httpclient and there is some code that uses >jdk 1.4 feature if available and implements a custom way for the connect timeout if they are not. I'm reclassifying this issue as an improvement slated for the 2.0 release, which is allowed to use JDK 1.4/1.5 features. We've got to discuss on commons-dev a bit how best to support connection timeouts. Do we want to add a slew of connect methods to SocketClient that take timeout parameters (this would be nicer if Java supported default argument values)? Or do we want to add a setConnectionTimeout (easier change, but awkward)?
My bias is to add only one or two connect methods that correspond to the two Socket.connect methods that require a SocketAddress argument. This avoids having a ton of different version of connect. Another thing to consider (separate issue) is if we need to deprecate SocketFactory and move to javax.net.SocketFactory and javax.net.ServerSocketFactory. Unfortunately, the javax.net classes are not interfaces, so I don't think we can abandon SocketFactory. However, as part of this issue, a createSocket() method must be added that creates an unconnected Socket. We use that to create the socket and then the JDK 1.4 Socket.connect to establish the socket connection with a timeout. At any rate, that's my proposal (two new SocktClient.connect methods and one new SocketFactory/DefaultSocketFactory.createSocket() method) . If Rory, Steve, and company don't object, I'll make the change to the 2.0 tree either this weekend or the following weekend. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||