Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Establishing a different *default* java.net.Socket read timeoutvalue...

Reply
Thread Tools

Establishing a different *default* java.net.Socket read timeoutvalue...

 
 
joe.no_junk@gmail.com
Guest
Posts: n/a
 
      12-11-2007
Hi all.

I would like to figure out a way to get every socket created by any
code
in the JVM time out if a socket read is not responded to in X seconds.
I
made the cheap hack to java.net.Socket to internally call
self.setSoTimeout()
just before returning in every constructor, and that does the trick,
but
is there a non-bootclasspath-hacking way of doing it?
thanks,
Joe
 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      12-12-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hi all.
>
> I would like to figure out a way to get every socket created by any
> code
> in the JVM time out if a socket read is not responded to in X seconds.
> I
> made the cheap hack to java.net.Socket to internally call
> self.setSoTimeout()
> just before returning in every constructor, and that does the trick,
> but
> is there a non-bootclasspath-hacking way of doing it?
> thanks,


DO NOT rewrite java.* or javax.* classes.

Just subclass or delegate the functionality.

--
Lew
 
Reply With Quote
 
 
 
 
joe.no_junk@gmail.com
Guest
Posts: n/a
 
      12-12-2007
On Dec 11, 6:33 pm, Lew <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > Hi all.

>
> > I would like to figure out a way to get every socket created by any
> > code
> > in the JVM time out if a socket read is not responded to in X seconds.
> > I
> > made the cheap hack to java.net.Socket to internally call
> > self.setSoTimeout()
> > just before returning in every constructor, and that does the trick,
> > but
> > is there a non-bootclasspath-hacking way of doing it?
> > thanks,

>
> DO NOT rewrite java.* or javax.* classes.
>
> Just subclass or delegate the functionality.
>
> --
> Lew


No can do. The idea is that *any* socket that *any*
code running in the JVM (third-party JDBC drivers
for instance) operate sockets with a timeout. We
have no access to the code that is making most
of the sockets.
 
Reply With Quote
 
Gordon Beaton
Guest
Posts: n/a
 
      12-12-2007
On Tue, 11 Dec 2007 20:56:15 -0800 (PST), (E-Mail Removed) wrote:
> No can do. The idea is that *any* socket that *any*
> code running in the JVM (third-party JDBC drivers
> for instance) operate sockets with a timeout. We
> have no access to the code that is making most
> of the sockets.


How can you be certain that they will handle the potentially
unexpected (and certainly undocumented) timeout properly?

I would never recommend actually doing what you are asking, but
perhaps Socket.setSocketImplFactory() is what you are looking for.

/gordon

--
 
Reply With Quote
 
joe.no_junk@gmail.com
Guest
Posts: n/a
 
      12-12-2007
On Dec 11, 10:56 pm, Gordon Beaton <(E-Mail Removed)> wrote:
> On Tue, 11 Dec 2007 20:56:15 -0800 (PST), (E-Mail Removed) wrote:
> > No can do. The idea is that *any* socket that *any*
> > code running in the JVM (third-party JDBC drivers
> > for instance) operate sockets with a timeout. We
> > have no access to the code that is making most
> > of the sockets.

>
> How can you be certain that they will handle the potentially
> unexpected (and certainly undocumented) timeout properly?
>
> I would never recommend actually doing what you are asking, but
> perhaps Socket.setSocketImplFactory() is what you are looking for.
>
> /gordon
>
> --


Drivers already have code to handle unexpected disconnects,
which manifest themselves in failed reads. The issue I'm trying
to deal with are people who test product failure capabilities
by pulling the network cable from the DBMS box. This causes socket
reads to hang for *ten minutes* until the local OS's TCPTIMEOUT
aborts the read. For drivers and other third-party code there is
no direct access to their sockets to either initialize them with
a timeout, or to free up the threads that hang. I did look into
setSocketImplFactory(), but I didn't find any public SocketImpl
to subclass. I can recommend the customer tweak their OS to have
a shorter TCP TIMEOUT values, but that affects every process. My
hack at least limited the change to the single JVM...
thanks,
Joe
 
Reply With Quote
 
Gordon Beaton
Guest
Posts: n/a
 
      12-12-2007
On Wed, 12 Dec 2007 07:48:39 -0800 (PST), (E-Mail Removed) wrote:
> I did look into setSocketImplFactory(), but I didn't find any public
> SocketImpl to subclass.


I think that's what java.net.SocketImpl is for.

http://java.sun.com/javase/6/docs/te...dingSocks.html

/gordon

--
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why the lcp establishing procedure failed? asummit Cisco 2 06-12-2005 04:19 AM
Establishing FF Login PW Herb Firefox 1 01-15-2005 05:36 AM
Establishing Bluetooth network connection with PDA news.microsoft.com Wireless Networking 0 11-22-2004 03:12 PM
Establishing a VPN connection to an at home employee Paul Cisco 4 02-13-2004 07:39 AM
PRI E1 Controller Resets and Calls not re-establishing Jed Renton Cisco 0 11-05-2003 12:20 AM



Advertisments