Results 1 to 3 of 3
  1. #1
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default 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

  2. #2
    literallyjer is offline Member
    Join Date
    Oct 2009
    Posts
    25
    Rep Power
    0

    Default

    Have you looked at the API?

    Socket (Java Platform SE 6)

  3. #3
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    setSoTimeout(int) ?

    Enable/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, it is for a already-stablished connection, correct me if im wrong

    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

  1. connection timed out in my java code
    By santhosh_el in forum AWT / Swing
    Replies: 4
    Last Post: 10-22-2009, 01:24 PM
  2. solution for connection timed out
    By santhosh_el in forum Networking
    Replies: 0
    Last Post: 10-03-2009, 08:55 AM
  3. i am getting connection timed out
    By santhosh_el in forum Networking
    Replies: 1
    Last Post: 08-25-2009, 07:57 AM
  4. Replies: 1
    Last Post: 08-07-2007, 07:03 AM
  5. Replies: 1
    Last Post: 07-27-2007, 11:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •