commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Savarese (JIRA)" <j...@apache.org>
Subject [jira] Updated: (NET-141) Add connection timeout support to SocketClient and/or SocketFactory/DefaultSocketFactory
Date Tue, 26 Sep 2006 15:26:52 GMT
     [ http://issues.apache.org/jira/browse/NET-141?page=all ]

Daniel Savarese updated NET-141:
--------------------------------

          Summary: Add connection timeout support to SocketClient and/or SocketFactory/DefaultSocketFactory
 (was: FTPClient/DefaultSocketFactory does not regard default timeout)
       Issue Type: Improvement  (was: Bug)
    Fix Version/s: 2.0
         Assignee: Daniel Savarese

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.

> Add connection timeout support to SocketClient and/or SocketFactory/DefaultSocketFactory
> ----------------------------------------------------------------------------------------
>
>                 Key: NET-141
>                 URL: http://issues.apache.org/jira/browse/NET-141
>             Project: Commons Net
>          Issue Type: Improvement
>    Affects Versions: 1.4 Final
>            Reporter: Christian Hufgard
>         Assigned To: Daniel Savarese
>             Fix For: 2.0
>
>         Attachments: CustomSocketFactory.java
>
>
> Hi,
> If executing the following code
>  String hostname = "localhost";
>  FTPClient client = new FTPClient();
>  client.setDefaultTimeout(1000);
>  client.connect(hostname);
> against a ftp server that ignores the connection attempt (e.g. is firewalled/malfunctoned),
there will be no exception after 1000 ms. The exception will be thrown after a default timeout
of three minutes. (Three minutes on a debian/ and a suse machines. Might be different on other
platforms).
> JavaDoc says:
> public void setDefaultTimeout(int timeout)
>   Set the default timeout in milliseconds to use when opening a socket.
> Digging through the code I found, that DefaultSocketFactory which is used be SocketClient
does not care about any value set with this method. It creates a new Socket with Socket(hostname,
port) and relies on the VMs behaviour.
> To get this fixed I set a custom SocketFactory with client.setSocketFactory(socketFactory);
that uses a timeout for socket connection.
> This bug is also in 1.4.1, but this value is not listed...
> Christian

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message