URL.openStream() timeout value?

Discussion in 'Java' started by Tom Forsmo, Oct 24, 2006.

  1. Tom Forsmo

    Tom Forsmo Guest

    Does anybody know if its possible to set a timeout value when using URL
    to read a simple http request?

    I know URL uses the URLStreamHandler class to represents the different
    protocols, such as HTTP, that URL uses to perform the particular
    protocol operations, but I can not figure out if there is a way to set a
    timeout on the operation. I am not sure if there is an actual way in
    HTTP to set a timeout, but in that case its just as easy for URL to just
    close the connection if no reply has been received in X seconds.

    Any hints?

    tom
    Tom Forsmo, Oct 24, 2006
    #1
    1. Advertising

  2. Tom Forsmo wrote:
    >
    > Does anybody know if its possible to set a timeout value when using URL
    > to read a simple http request?
    >
    > I know URL uses the URLStreamHandler class to represents the different
    > protocols, such as HTTP, that URL uses to perform the particular
    > protocol operations, but I can not figure out if there is a way to set a
    > timeout on the operation. I am not sure if there is an actual way in
    > HTTP to set a timeout, but in that case its just as easy for URL to just
    > close the connection if no reply has been received in X seconds.
    >
    > Any hints?
    >
    > tom


    JDK 1.5 has a setTimeout method for URLConnection. I think this is the
    best you are going to get. You probably don't need a timeout on the
    getInput/OutputSream as you will have already connected or timed out as
    the case may be.

    --

    Knute Johnson
    email s/nospam/knute/
    Knute Johnson, Oct 24, 2006
    #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. Jon paugh
    Replies:
    1
    Views:
    701
  2. Replies:
    1
    Views:
    1,718
  3. Replies:
    1
    Views:
    392
    Esmond Pitt
    May 15, 2007
  4. Replies:
    2
    Views:
    447
  5. Mark Probert

    Timeout::timeout and Socket timeout

    Mark Probert, Oct 6, 2004, in forum: Ruby
    Replies:
    1
    Views:
    1,280
    Brian Candler
    Oct 6, 2004
Loading...

Share This Page