• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Thread on Socket?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello. I am curious how to monitor a socket connection? Meaning,
Lets say I have successfully made a connection, and for the period of my application, I need to monitor that connection. If the connection is lost, I have a list of conditionals to execute and same if the socket is remained open. So, I guess this is both a Threading and Socket Question, but I am totally lost on how to go about doing this. I would greatly appreciate any help possible.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rick!
I was working with this problem more than one year. At my job we were migrating some GSM staff to TCP/IP network. And finally we concluded that the bestest way to monitor the connection is to send "heartbeats" each other. Heartbeat is just 2 bytes message: 1st byte is header ("I am heartbeat") and second any value you agreed in you connection protocol.
Server sends to client, client sends to server. Lets say once per 2-5 minutes.
You should have timeout timer. If heartbeat doesn't in 5 minutes you are writting it and after n times of absence of heartbeats you closes connection (the threshold for quantity of missing heartbeats (3-10)).
This was the bestest way to be sure that servers are working and connection still alive. Because we met situation when server hanging in some state and keeps connection open but doesn't work and client thinks it is Ok. But is not.
Here the values for heartbeat (every 2-5 minutes) and threshhold for missing hearbeats 3-10 are taken from real life.
I hope I described this clear and it will help you (ask if ...)
alex from JavaFaq http://www.erudite-center.com/java
 
reply
    Bookmark Topic Watch Topic
  • New Topic