I have tried this before. It did not work for me under IBM's 1.3.1 JVM and Linux.
Otis _______________________________________________________________ Get your own FREE email account at iVillage.com! http://webmail.ivillage.com/ <-----Original Message-----> From: Mohammad M. Purbo Sent: 3/13/2002 8:02:36 PM To: [EMAIL PROTECTED] Subject: httpclient: timeout Hi All, i was just joining & have a question/suggestion. i downloaded commons-httpclient source code sometimes ago (nightly build: 20020307) to try to use it in one of my project, in which i need to set the timeout for a connection. i wrote something like: import org.apache.commons.httpclient.*; ..... HttpConnectionManager httpconn = ........ HttpUrlMethod method = ...... int timeout = 60000; HttpConnection connection = httpconn.getConnection(method.getUrl()); connection.setSoTimeout(timeout); int status = method.execute(getState(),connection); which of course wouldn't work because HttpConnectionManger.getConnection is not returning opened connection, and the connection wouldn't be opened until the execution of HttpMethodBase.execute. now, i couldn't find any way to set the timeout so that it can be set to the HttpConnection once it's opened inside HttpMethodBase.execute (except by overriding the execute method in my own Method-descendant class, which is a bit too much because it's almost as good as writing the whole HttpMethodBase). So I made a patch temporarily in HttpConnection: 1. add private member: private int _timeout = -1; 2. update setSoTimeout(): public void setSoTimeout(int timeout) throws SocketException, IllegalStateException { _timeout = timeout; } 3. update open(), and add the following lines just before _open = true; if (_timeout > 0) { _socket.setSoTimeout(_timeout); } Did i miss something? Thank you, M. Purbo -- To unsubscribe, e-mail: For additional commands, e-mail:
