Hola:
En Java 6 la clase que mencionas provee los metodos para definir el
TimeOut de conexion y de lectura. Ejemplo sacado de los JavaDocs:
setConnectTimeout
public void setConnectTimeout(int timeout)
Sets a specified timeout value, in milliseconds, to be used when opening a
communications link to the resource referenced by this URLConnection. If
the timeout expires before the connection can be established, a
java.net.SocketTimeoutException is raised. A timeout of zero is
interpreted as an infinite timeout.
Some non-standard implmentation of this method may ignore the specified
timeout. To see the connect timeout set, please call getConnectTimeout().
Parameters:
timeout - an int that specifies the connect timeout value in milliseconds
Throws:
IllegalArgumentException - if the timeout parameter is negative
Since:
1.5
See Also:
getConnectTimeout(), connect()
setReadTimeout
public void setReadTimeout(int timeout)
Sets the read timeout to a specified timeout, in milliseconds. A non-zero
value specifies the timeout when reading from Input stream when a
connection is established to a resource. If the timeout expires before
there is data available for read, a java.net.SocketTimeoutException is
raised. A timeout of zero is interpreted as an infinite timeout.
Some non-standard implementation of this method ignores the specified
timeout. To see the read timeout set, please call getReadTimeout().
Parameters:
timeout - an int that specifies the timeout value to be used in milliseconds
Throws:
IllegalArgumentException - if the timeout parameter is negative
Since:
1.5
See Also:
getReadTimeout(), InputStream.read()
Saludos,
--
Dinámica - Framework Java/Ajax
100% software libre
http://www.martincordova.com
> Buenos días.
>
>
>
> Estoy realizando una aplicación que me permita enviar y recibir datos
> hacia
> un servidor HTTP, y hasta ahora he logrado realizar los envíos sin
> problemas, pero en algunos casos, cuando estoy haciendo la lectura, la
> conexión se corta por timeout.
>
>
>
> Utilizo la clase java.net.URLConnection, pero no encuentro manera de
> controlar el tiempo de espera de una respuesta (readTimeOut), y mucho
> menos
> el de conexión (connectionTimeOut).
>
>
>
> ¿Alguna sugerencia de cómo controlar el timeout?
>
>
>