Results 1 to 3 of 3
Thread: Connection Timed Out
- 10-25-2009, 02:46 PM #1
Connection Timed Out
I have created a simple server, using ServerSocket/Socket and a client using Socket
I'm currently on debugging period where i found out that it takes 2 to 3 minutes before the client will throw an ConnectionException: Connection timed out
Supposedly, i have a simple server, together with the client at the same machine, and most likely we always use the loopback(127.0.0.1) address when we try to stablish a connection within the same machine. Base on the specification(this experiment), A loopback address OR a public address must also satisfies the required ip address to be able to connect the client unto the server. However, i expect that the client cannot connect directly to the server if the port is not forwarded(Port forwarding not enabled), so my question is,
Is it possible to control the time to wait @ Socket until it throws a ConnectionException: Connection timed out?
Or it depends on the protocol?freedom exists in the world of ideas
- 10-26-2009, 04:36 PM #2
Member
- Join Date
- Oct 2009
- Posts
- 25
- Rep Power
- 0
Have you looked at the API?
Socket (Java Platform SE 6)
- 10-27-2009, 03:20 PM #3
setSoTimeout(int) ?
But, it is for a already-stablished connection, correct me if im wrongEnable/disable SO_TIMEOUT with the specified timeout, in milliseconds. With this option set to a non-zero timeout, a read() call on the InputStream associated with this Socket will block for only this amount of time. If the timeout expires, a java.net.SocketTimeoutException is raised, though the Socket is still valid. The option must be enabled prior to entering the blocking operation to have effect. The timeout must be > 0. A timeout of zero is interpreted as an infinite timeout.
But the problem is, it takes 2 to 3 minutes before it recognizes that it can't connect to a given valid ip address and port. i have an alternative solution with this one(Interrupt), but for simplification, any other idea?freedom exists in the world of ideas
Similar Threads
-
connection timed out in my java code
By santhosh_el in forum AWT / SwingReplies: 4Last Post: 10-22-2009, 12:24 PM -
solution for connection timed out
By santhosh_el in forum NetworkingReplies: 0Last Post: 10-03-2009, 07:55 AM -
i am getting connection timed out
By santhosh_el in forum NetworkingReplies: 1Last Post: 08-25-2009, 06:57 AM -
using Java to access a secure webpage, Exception occurred: Connection timed out
By toby in forum Enterprise JavaBeans (EJB)Replies: 1Last Post: 08-07-2007, 06:03 AM -
Exception in thread "main" java.net.ConnectException: Connection timed out
By osval in forum Advanced JavaReplies: 1Last Post: 07-27-2007, 10:59 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks