Article View: borland.public.jbuilder.java.api
Article #1379Re: Socket Connection Timeout
From: Owen Green
Date: Sat, 09 Feb 2002 11:10
Date: Sat, 09 Feb 2002 11:10
31 lines
2293 bytes
2293 bytes
Jonathan Taub <jonathantaub@hotmail.com> wrote in message news:3c64f657_2@dnews... > I'm not sure I understand your question. > There is a method in the Socket class: > > public void setSoTimeout(int timeout) > > Perhaps this is what you are looking for. > Thanks, I knew about that :) No, what I was asking was about graceful ways of handling timeouts when the socket actually connects (i.e. when the instance is created). The only advice I have seen so far (in the Javaworld article I mentioned above) is to create the instance in a seperate thread (probably an inner class of one's socket wrapper) so that the main thread can handle any potential timeout without blocking (by default the connection timeout seems to be a significant amount of time). The problem with this approach, as I see it, is that if one has a largish number of sockets, and they're all timing out when they try to connect, then you will have a large number of now redundant threads hanging about until each call to new Socket() returns. This seems to be unavoidable, barring the possibiltiy of getting an implementation of SocketImpl with a configurable connection timeout, so my thoughts have now turned to whether there's any mileage in trying to manage these background threads in some way to minimise the potential load if things go wrong. Cheers for your response, Owen
Technical Details
Message-ID:
<3c65025a_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!isdnet!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!dnewsReferences:
<3c5e8c56_2@dnews> <3c64f657_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,d42f491dc8467f1b X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2002-02-09 03:09:06 PST From: "Owen Green" <owen@begonefoulmachine.kennulz.demon.co.uk> Newsgroups: borland.public.jbuilder.java.api References: <3c5e8c56_2@dnews> <3c64f657_2@dnews> Subject: Re: Socket Connection Timeout Date: Sat, 9 Feb 2002 11:10:12 -0000 Lines: 33 Organization: Unique Interactive X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 NNTP-Posting-Host: 217.134.96.249 Message-ID: <3c65025a_1@dnews> X-Trace: dnews 1013252698 217.134.96.249 (9 Feb 2002 03:04:58 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!isdnet!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!dnews