Results 1 to 2 of 2

Thread: Socket Timeout?

  1. #1
    Moncleared is offline Member
    Join Date
    Jan 2009
    Rep Power

    Default Socket Timeout?

    So I have a Server-Client application I am creating and heres my problem.

    When the server disconnects, crashes, or a i shut it down (what I'm getting at, is its unexpected), the clients on the other end have no idea that the server has disappeared until sometime later.

    I believe the clients find out at some point of a TimeOut but they do eventually find out. I want a creative way to check maybe every 15 seconds whether the server is still there. I've looked up and down the Socket api for methods I could use. For example, there is a method


    But even after I close my server this method returns true for some while.

    Any ideas?

  2. #2
    Mr.Beans's Avatar
    Mr.Beans is offline Senior Member
    Join Date
    Apr 2009
    Virginia Beach, Virginia
    Rep Power


    If you look at the java api doc for the isConnected method() it says it

    returns true if the socket successfully connected to a server
    I'm going to assume that once the socket has connected to the server it will continue to return true.

    One way would to simply send a packet and see if the server responds every 15 seconds. if it doesn't respond then something is wrong.

Similar Threads

  1. Implement a timeout
    By pjmorce in forum Advanced Java
    Replies: 5
    Last Post: 04-27-2010, 03:36 AM
  2. append response to the request from Socket and write to another socket
    By in forum Networking
    Replies: 3
    Last Post: 04-17-2009, 08:02 PM
  3. session timeout
    By nmbalaji in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 12-12-2008, 05:04 PM
  4. Threads and Timeout in Socket Networking
    By byuu in forum Threads and Synchronization
    Replies: 2
    Last Post: 05-27-2008, 10:05 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