connect timeout

B

bob smith

Is there any way to specify the connection timeout for a java.net.Socket?

I might want something like this to throw a ConnectException within 10 seconds:

Socket socket = new Socket(ip_address, 80);

Thanks.
 
A

Arne Vajhoej

BTW, do you know what that means that the default is -1?

sun.net.client.defaultConnectTimeout (default: -1)
sun.net.client.defaultReadTimeout (default: -1)

I assume -1 means not set.

Arne
 
J

John B. Matthews

Arne Vajhoej said:
I assume -1 means not set.

This would comport with how -1 is used elsewhere in the cited document
to mean "forever," perhaps in the sense of "no specified timeout."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top