The two timeouts apply at different layers in the networking stack.  The
connect timeout (I believe) is an application layer timeout used to break
when the connection is not established within x milliseconds whereas the so
timeout is an ip layer timeout used during the low level read/write of the
packets.

To read about these some backround on tcp/ip would help; as well as the java
tutorials here<http://java.sun.com/docs/books/tutorial/networking/index.html>and
documentation socket options documentation
here <http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html>
.

Raymond

On 8/16/07, Vitaly Baranovsky <[EMAIL PROTECTED]> wrote:
>
> > you are setting a socket timeout, not a connect timeout. No wonder you
> are not getting the
> > expected result.
>
> What is the difference between socket timeout and connect timeout? Can
> I read about this difference somewhere?
>
> 2007/8/15, Oleg Kalnichevski <[EMAIL PROTECTED]>:
> > On Wed, 2007-08-15 at 17:56 +0300, Vitaly Baranovsky wrote:
> > > Good day!
> > >
> > > Connection timeouts of httpClient in my program doesn't works. I set
> > > timeout to 10 000 milliseconds, but my program waits for about 65
> > > seconds before answering.
> >
> > ...
> >
> > > Here is the code of my class:
> > >
> > > public class HttpGetter {
> > >
> > > private static final int DEFAULT_SOCKET_TIMEOUT = 10000;
> > > private HttpClient httpClient;
> > > private GetMethod method;
> > >
> > > public HttpGetter() {
> > > super();
> > > MultiThreadedHttpConnectionManager cm = new
> > > MultiThreadedHttpConnectionManager();
> > > cm.getParams().setSoTimeout(DEFAULT_SOCKET_TIMEOUT);
> > >
> >
> > Hi Vitaly,
> >
> > On top of what Pete Keyes just said, in your code you are setting a
> > socket timeout, not a connect timeout. No wonder you are not getting the
> > expected result.
> >
> > Oleg
> >
> >
> > > httpClient = new HttpClient(cm);
> > > }
> > >
> > > private String getFromURLAsString(String url) throws HttpException,
> > > IOException {
> > >   URI uri = new URI(url, false);
> > >   method = new GetMethod(uri.getEscapedURI());
> > >   method.getParams().setSoTimeout(DEFAULT_SOCKET_TIMEOUT);
> > >   int result = httpClient.executeMethod(method);
> > >   return method.getResponseBodyAsString();;
> > > }
> > > }
> > >
> > >
> > >
> > > Here is the code of my TestCase:
> > >
> > > public class HttpGetterTest extends TestCase {
> > >       public void testGetFromUrlAsString() throws HttpException,
> IOException{
> > >               HttpGetter httpGetter = new HttpGetter();
> > >               System.out.println(httpGetter.getFromURLAsString("
> http://google.com";));
> > >       }
> > > }
> > >
> > >
> > > Why timeouts doesn't works?
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail:
> [EMAIL PROTECTED]
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> With best regards,
> Vitaly Baranovsky
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
--------------------------------------------------------------------------------
Raymond Kroeker
thinkParity Solutions Inc.

Reply via email to