Re: Help on Socket and URLConnection



Mudit Khetan wrote:
Hi all,
I am trying to make some tutorial assignmemnts and example programs for
my classes. I'm trying to use the 'Socket' and 'URLConnection' classes.
I am wondering if I can set a timeOut and catch the exception when the
connection times out. I'am implementing a simple webserver for which i
need this facility.
Thanks
Generally or usually, if you use URLConnection, a higer level of remote
connection abstraction than Socket, you won't need Socket for your
application. URLConnection class has setReadTimeout() method for which
read operation would throw java.net.SocketTimeoutException when the
timeout expired.

.