BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

What the default timeout when new Socket()?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder JavaAPI
View previous topic :: View next topic  
Author Message
Chris Wahl
Guest





PostPosted: Sun Dec 19, 2004 5:12 pm    Post subject: What the default timeout when new Socket()? Reply with quote



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





PostPosted: Sun Dec 19, 2004 6:57 pm    Post subject: Re: What the default timeout when new Socket()? Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder JavaAPI All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.