Preventing eternal hang

Discussion in 'Java' started by Ike, Dec 20, 2004.

  1. Ike

    Ike Guest

    Is there a way I can wrap the following in such a manner such that if no
    value is returned by after X seconds, the method throws an IOException ?

    private InputStream getFromServlet( URLConnection uc) throws
    java.io.IOException {
    return uc.getInputStream();
    }

    I know in 1.5 this is built into getInputStream, but I need compatibility to
    lower-version JVMs. Thanks, Ike
     
    Ike, Dec 20, 2004
    #1
    1. Advertising

  2. I would put it in a separate thread. You can interrupt this thread after
    a timeout. It should work


    Ike wrote:
    > Is there a way I can wrap the following in such a manner such that if no
    > value is returned by after X seconds, the method throws an IOException ?
    >
    > private InputStream getFromServlet( URLConnection uc) throws
    > java.io.IOException {
    > return uc.getInputStream();
    > }
    >
    > I know in 1.5 this is built into getInputStream, but I need compatibility to
    > lower-version JVMs. Thanks, Ike
    >
    >
     
    Andrea Desole, Dec 20, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Socket Hang

    , Aug 26, 2003, in forum: Perl
    Replies:
    0
    Views:
    2,064
  2. Craig Pearson

    IIS/ASP.NET Hang

    Craig Pearson, Nov 23, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    444
    Natty Gur
    Nov 24, 2003
  3. =?Utf-8?B?UGF1bA==?=

    Eternal Debate: Cookies vs. Sessions vs. QueryString

    =?Utf-8?B?UGF1bA==?=, Dec 9, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    4,710
    m.posseth
    Dec 12, 2005
  4. BruceS

    eternal-september & Pan

    BruceS, Aug 27, 2012, in forum: C Programming
    Replies:
    8
    Views:
    484
    Jorgen Grahn
    Aug 28, 2012
  5. Alain Ketterlin
    Replies:
    2
    Views:
    168
    Terry Reedy
    Jan 8, 2013
Loading...

Share This Page