Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #19427

Re: detecting Socket disconnect

From Roedy Green <see_website@mindprod.com.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: detecting Socket disconnect
Date 2012-10-17 15:52 -0700
Organization Canadian Mind Products
Message-ID <sddu78lb0ja7bc85u10a0eqrfbk7dq6lst@4ax.com> (permalink)
References <c46d29c6-f804-43da-b748-ef50c3a8bdfa@googlegroups.com>

Show all headers | View raw


On Wed, 17 Oct 2012 13:12:13 -0700 (PDT), bob smith
<bob@coolfone.comze.com> wrote, quoted or indirectly quoted someone
who said :

>Anyone know how to detect the disconnect?

I wrestled with the problem and solved it with a custom protocol
sending packets back and forth.  

If there is no traffic, it sends a "heartbeat" packet every X seconds,
just to let the other end know it is alive. The receiver just ignores
them.  If a read times out, it presumes the worst and restarts the
socket.

TCP/IP is quite happy with no traffic for long periods of time, so it
is up to you if you want early notification.
-- 
Roedy Green Canadian Mind Products http://mindprod.com
There are four possible ways to poke a card into a slot.
Nearly always, only one way works. To me that betrays a 
Fascist mentality, demanding customers conform to some 
arbitrary rule, and hassling them to discover the magic 
orientation. The polite way to do it is to design the reader 
slot so that all four ways work, or so that all the customer 
has to do is put the card in the vicinity of the reader. 

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

detecting Socket disconnect bob smith <bob@coolfone.comze.com> - 2012-10-17 13:12 -0700
  Re: detecting Socket disconnect Arne Vajhoej <arne@vajhoej.dk> - 2012-10-17 16:45 -0400
  Re: detecting Socket disconnect Lew <lewbloch@gmail.com> - 2012-10-17 13:47 -0700
    Re: detecting Socket disconnect Arne Vajhoej <arne@vajhoej.dk> - 2012-10-17 17:19 -0400
  Re: detecting Socket disconnect Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-10-17 13:59 -0700
    Re: detecting Socket disconnect Arne Vajhoej <arne@vajhoej.dk> - 2012-10-17 17:24 -0400
      Re: detecting Socket disconnect Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-10-17 14:42 -0700
    Re: detecting Socket disconnect Steven Simpson <ss@domain.invalid> - 2012-10-18 09:31 +0100
      Re: detecting Socket disconnect Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-10-18 07:09 -0700
  Re: detecting Socket disconnect Martin Gregorie <martin@address-in-sig.invalid> - 2012-10-17 21:14 +0000
  Re: detecting Socket disconnect Roedy Green <see_website@mindprod.com.invalid> - 2012-10-17 15:52 -0700

csiph-web