i’m looking for a way to set the connection timeout on a URL object. the only way i found of doing this at the moment is by setting the following property : sun.net.client.defaultConnectTimeout

but when you read this : These properties may not be supported in future releases. then i don’t think this is the right way of doing it … but it works like a charm :)

      System.getProperties().put( “sun.net.client.defaultConnectTimeout”, “1” );
      url = new URL (“http://www.google.com”);
      start = System.currentTimeMillis();
      try {
         url.openStream();
      } catch (e) {
         print(e);
      }
      stop = System.currentTimeMillis();
      print(stop - start);

this is why i love beanshell, you can very quickly test this kind of stuff :)


Date
October 9, 2003