🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.api
2 messages
2 total messages Started by Chris Wahl Sun, 19 Dec 2004 17:12
What the default timeout when new Socket()?
#21
Author: Chris Wahl
Date: Sun, 19 Dec 2004 17:12
8 lines
1090 bytes
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
Re: What the default timeout when new Socket()?
#22
Author: Shankar Unni
Date: Sun, 19 Dec 2004 18:57
32 lines
2634 bytes
Chris Wahl wrote:
> 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.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads