Re: How to tell if the other end of socket connection is dead without polling?



Nick Toop wrote:
Hi,

I have a Java application which runs a server socket on a PC. Various
sensors (using microprocessors) can call it up and each gets its own thread
running the socket connection.

The sensors send in data at random times. This all works OK.

Sometimes one of the sensors fails or goes off-line. How can I tell from
the server end? If they fail I would like to close the link down.

Obviously I could poll links on a periodic basis and mark the link as dead
after a specified timeout but this seems rather inelegant. If I chose a
short period the network might be very busy for a short time and cause a
false timeout. If the period is long then I either have to start a new
thread to handle the polling or elselive with my main application blocking.
Anyway, there might be several hundred sensors and I don't want to clutter
the network up with polling packets. Is there a better way?

I would be grateful for any help.

Regards,

Nick


If you don't send data on a TCP stream, nothing is sent. There is no
detection of crashes built into the TCP protocol, so you will have to
implement this yourself.

On the client side I usually mark the time of the last packet sent and
use that for determining when a keepalive packet needs to be sent
meaning that if the application itself sends and receives data regularly
no keepalive packets needs to be sent at all. Only when the stream is
idle will I send keepalives.

On the server side I mark the time of the last received packet from each
client and have a timer to check the clients. If the server hasn't heard
from the clients in a configurable amount of time the stream is shut down.
.



Relevant Pages

  • Need example or recommendation for good book
    ... The plan is to deploy approximately 50 sensors at different location. ... will collect the data and send them to the server which will put them ... Now what we want on the web app is to create a website which allows ...
    (microsoft.public.dotnet.framework.aspnet)
  • ISS Site Protector WAN Performance Issues
    ... SiteProtector server generates when it opens the control channel to the ... Sensors to get system information. ... The average load is averaging ... The event collector has nothing to do with this, ...
    (comp.security.misc)
  • ISS Site Protector WAN Performance Issues
    ... SiteProtector server generates when it opens the control channel to the ... Sensors to get system information. ... The average load is averaging ... The event collector has nothing to do with this, ...
    (comp.security.firewalls)
  • Re: ISS Site Protector WAN Performance Issues
    ... >> is generated by the Real Secure Sensors. ... > connect to it over the WAN link either via terminal services session, VNC, ... Alex ... The SP server is at the location with the most sensors. ...
    (comp.security.firewalls)
  • Re: ISS Site Protector WAN Performance Issues
    ... >> is generated by the Real Secure Sensors. ... > connect to it over the WAN link either via terminal services session, VNC, ... Alex ... The SP server is at the location with the most sensors. ...
    (comp.security.misc)