 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Chris Wahl Guest
|
Posted: Sun Dec 19, 2004 5:12 pm Post subject: What the default timeout when new Socket()? |
|
|
According to Javadoc, it is 0, ie, no timeout,
but my progie really throw Exception:
java.net.ConnectException: Connection timed out: connect
Any hint?
Regards.
TIA
|
|
| Back to top |
|
 |
Shankar Unni Guest
|
Posted: Sun Dec 19, 2004 6:57 pm Post subject: Re: What the default timeout when new Socket()? |
|
|
Chris Wahl wrote:
| Quote: | According to Javadoc, it is 0, ie, no timeout,
but my progie really throw Exception:
java.net.ConnectException: Connection timed out: connect
|
What that's saying is that it won't return a Java-library-imposed
timeout. You are still subject to the underlying networking layer's
timeouts *or errors*.
The timeouts can come for a variety of reasons:
* The address is invalid. This one should throw an exception right away,
but could be subject to DNS timeouts, especially if your DNS is
misconfigured.
* The address is correct, but there is no service listening on that
port. This will usually error out right away (with perhaps a small wait).
* The address is correct, and there is a service there, but it's hung or
busy (or otherwise not accept()ing your connection). This is where the
network-imposed connect timeout comes in.
* There is a firewall in between that is rejecting you, but is just
dropping the packets into the Great Bit Bucket In The Sky (the usual
behavior of firewalls, for good reason). This is subject to the TCP
layer timeouts.
The "Socket("host", port)" constructor is basically shorthand for
Socket s = new Socket();
s.connect("host", port); // the "0"-timeout variant.
If you call s.connect("host", port, timeout), then the call will time
out after the *earlier* of your timeout and the OS layer-imposed timeout
or error.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|