X-Received: by 10.66.227.7 with SMTP id rw7mr998067pac.19.1360944462391; Fri, 15 Feb 2013 08:07:42 -0800 (PST) X-Received: by 10.49.34.135 with SMTP id z7mr102779qei.1.1360944462334; Fri, 15 Feb 2013 08:07:42 -0800 (PST) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!usenet.blueworldhosting.com!news.glorb.com!su1no3777040pbb.0!news-out.google.com!jm3ni9pbb.0!nntp.google.com!kc14no3771906pbb.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Fri, 15 Feb 2013 08:07:40 -0800 (PST) In-Reply-To: <511e3c98$0$284$14726298@news.sunsite.dk> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=184.76.139.203; posting-account=i_CD_goAAABP7bi9ZMrA_X4KayPX2l7I NNTP-Posting-Host: 184.76.139.203 References: <511e3c98$0$284$14726298@news.sunsite.dk> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <2ba5b10c-34c4-4e2d-bb27-047f77340436@googlegroups.com> Subject: Re: connect timeout From: mike7411@gmail.com Injection-Date: Fri, 15 Feb 2013 16:07:42 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: csiph.com comp.lang.java.programmer:22326 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)