unblocking a call to URLConnection.getInputStream
Posted on 2002-03-14
I have an interesting problem with an applet in Internet Explorer on win98 machines using a dialup.
Specifically the application in question retrieves a urlconnection from a url object and calls getInputStream to read a serialized object from the server.
The problem comes into play when the dialup user disconnects their modem. At that point the call to URLConnection.getInputStream() blocks and never returns.
The creation of the urlconnection does not fail or throw an exception after the dialup is disconnected and a call to urlconnection.connect doesnt either.
When running a similar test on a network where I pull the plug I get an exception with the following stack trace which makes sense.
The hanging behavior also appears to be inconsistent and doesnt occur every time the dialup is disconnected and reconnected.
The question is can I construct my attempts to get an input stream to force an exception in the case that the client machine has disconnected his internet session or alternatively is there a reasonable way to have another thread force the getInputStream call to unblock, or alternatively does anyone have a good suggestion on how to get at the connected property of the URLConnection so I could avoid trying to get the inputstream at all in this scenario?
Thanks for any suggestions