Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #22309 > unrolled thread

connect timeout

Started bybob smith <bob@coolfone.comze.com>
First post2013-02-14 11:22 -0800
Last post2013-02-16 13:21 -0500
Articles 7 — 5 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  connect timeout bob smith <bob@coolfone.comze.com> - 2013-02-14 11:22 -0800
    Re: connect timeout Lew <lewbloch@gmail.com> - 2013-02-14 12:38 -0800
    Re: connect timeout Arne Vajhoej <arne@vajhoej.dk> - 2013-02-15 08:48 -0500
      Re: connect timeout Lew <lewbloch@gmail.com> - 2013-02-15 07:21 -0800
      Re: connect timeout mike7411@gmail.com - 2013-02-15 08:07 -0800
        Re: connect timeout Arne Vajhoej <arne@vajhoej.dk> - 2013-02-15 12:05 -0500
          Re: connect timeout "John B. Matthews" <nospam@nospam.invalid> - 2013-02-16 13:21 -0500

#22309 — connect timeout

Frombob smith <bob@coolfone.comze.com>
Date2013-02-14 11:22 -0800
Subjectconnect timeout
Message-ID<c45c592d-9d52-490b-b2d0-66eaaff38123@googlegroups.com>
Is there any way to specify the connection timeout for a java.net.Socket?

I might want something like this to throw a ConnectException within 10 seconds:

Socket socket = new Socket(ip_address, 80);

Thanks.

[toc] | [next] | [standalone]


#22310

FromLew <lewbloch@gmail.com>
Date2013-02-14 12:38 -0800
Message-ID<91f39950-71c9-467f-b6a5-e861442eff61@googlegroups.com>
In reply to#22309
bob smith wrote:
> Is there any way to specify the connection timeout for a java.net.Socket?
> 
> I might want something like this to throw a ConnectException within 10 seconds:
> 
> Socket socket = new Socket(ip_address, 80);

http://docs.oracle.com/javase/7/docs/api/java/net/Socket.html

HTH.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#22319

FromArne Vajhoej <arne@vajhoej.dk>
Date2013-02-15 08:48 -0500
Message-ID<511e3c98$0$284$14726298@news.sunsite.dk>
In reply to#22309
On 2/14/2013 2:22 PM, bob smith wrote:
> Is there any way to specify the connection timeout for a java.net.Socket?
>
> I might want something like this to throw a ConnectException within 10 seconds:
>
> Socket socket = new Socket(ip_address, 80);

http://docs.oracle.com/javase/7/docs/technotes/guides/net/properties.html

explains how to change default connect and read timeout for SUN/Oracle
implementation.

Arne

[toc] | [prev] | [next] | [standalone]


#22324

FromLew <lewbloch@gmail.com>
Date2013-02-15 07:21 -0800
Message-ID<8ccab9d7-d86a-40c5-bf0f-1bdea1c5237d@googlegroups.com>
In reply to#22319
Arne Vajhoej wrote:
> bob smith wrote:
>> Is there any way to specify the connection timeout for a java.net.Socket?
> 
>> I might want something like this to throw a ConnectException within 10 seconds:
>
>> Socket socket = new Socket(ip_address, 80);
> 
> http://docs.oracle.com/javase/7/docs/technotes/guides/net/properties.html
> 
> explains how to change default connect and read timeout for SUN/Oracle
> implementation.

The two-lines-of-code approach doesn't require an exogenous declaration of 
the property, which is an advantage if you don't want to rely on the correct
invocation of the program and a disadvantage if you want the same code to 
handle different configurations.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#22326

Frommike7411@gmail.com
Date2013-02-15 08:07 -0800
Message-ID<2ba5b10c-34c4-4e2d-bb27-047f77340436@googlegroups.com>
In reply to#22319
On Friday, February 15, 2013 7:48:11 AM UTC-6, Arne Vajhoej wrote:
> On 2/14/2013 2:22 PM, bob smith wrote:
> 
> > Is there any way to specify the connection timeout for a java.net.Socket?
> 
> >
> 
> > I might want something like this to throw a ConnectException within 10 seconds:
> 
> >
> 
> > Socket socket = new Socket(ip_address, 80);
> 
> 
> 
> http://docs.oracle.com/javase/7/docs/technotes/guides/net/properties.html
> 
> 
> 
> explains how to change default connect and read timeout for SUN/Oracle
> 
> implementation.
> 
> 
> 
> Arne

Thanks.

BTW, do you know what that means that the default is -1?

sun.net.client.defaultConnectTimeout (default: -1)
sun.net.client.defaultReadTimeout (default: -1)

[toc] | [prev] | [next] | [standalone]


#22327

FromArne Vajhoej <arne@vajhoej.dk>
Date2013-02-15 12:05 -0500
Message-ID<511e6aed$0$282$14726298@news.sunsite.dk>
In reply to#22326
On 2/15/2013 11:07 AM, mike7411@gmail.com wrote:
> On Friday, February 15, 2013 7:48:11 AM UTC-6, Arne Vajhoej wrote:
>> On 2/14/2013 2:22 PM, bob smith wrote:
>>> Is there any way to specify the connection timeout for a java.net.Socket?
>>> I might want something like this to throw a ConnectException within 10 seconds:
>>> Socket socket = new Socket(ip_address, 80);
>> http://docs.oracle.com/javase/7/docs/technotes/guides/net/properties.html
>> explains how to change default connect and read timeout for SUN/Oracle
>> implementation.
> BTW, do you know what that means that the default is -1?
>
> sun.net.client.defaultConnectTimeout (default: -1)
> sun.net.client.defaultReadTimeout (default: -1)

I assume -1 means not set.

Arne

[toc] | [prev] | [next] | [standalone]


#22331

From"John B. Matthews" <nospam@nospam.invalid>
Date2013-02-16 13:21 -0500
Message-ID<nospam-1C6134.13211616022013@news.aioe.org>
In reply to#22327
In article <511e6aed$0$282$14726298@news.sunsite.dk>,
 Arne Vajhoej <arne@vajhoej.dk> wrote:

> On 2/15/2013 11:07 AM, mike7411@gmail.com wrote:
> > On Friday, February 15, 2013 7:48:11 AM UTC-6, Arne Vajhoej wrote:
> >> On 2/14/2013 2:22 PM, bob smith wrote:
> >>> Is there any way to specify the connection timeout for a 
> >>> java.net.Socket? I might want something like this to throw a 
> >>> ConnectException within 10 seconds:
> >>> Socket socket = new Socket(ip_address, 80);
> >> http://docs.oracle.com/javase/7/docs/technotes/guides/net/properties.html
> >> explains how to change default connect and read timeout for 
> >> SUN/Oracle implementation.
> > BTW, do you know what that means that the default is -1?
> >
> > sun.net.client.defaultConnectTimeout (default: -1)
> > sun.net.client.defaultReadTimeout (default: -1)
> 
> I assume -1 means not set.

This would comport with how -1 is used elsewhere in the cited document
to mean "forever," perhaps in the sense of "no specified timeout."

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web