all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Determining whether a TCP connection is up
@ 2013-08-03 12:30 Lars Magne Ingebrigtsen
  2013-08-03 14:09 ` Paul Eggert
  2013-08-03 16:01 ` Julien Danjou
  0 siblings, 2 replies; 17+ messages in thread
From: Lars Magne Ingebrigtsen @ 2013-08-03 12:30 UTC (permalink / raw)
  To: emacs-devel

TCP connections may go AWOL in many different ways.  The most common
reasons are 1) changing IP address on a laptop, 2) the "router" changes
IP address when you're on a laptop tethered to a telephone, and 3) the
server dies.

In some cases (like in 1 and 2) you will perhaps get a TCP reset from
the server when you issue a command.  That's fine, and solves the
problem.

But, these days, most services are behind firewalls that just drop
packages that come on connections it doesn't know about.  So you get no
packets in return.  The same is true for 3).

So the only way to see whether a TCP connection is up is really to send
a command and see whether you get anything back.

Having to implement that kind of logic for all the network protocols is
tedious and can't be done generally.

For one, you have to establish reasonable timeouts, but there are none
that can be used generally.  For instance, when you send a DELETE
command to an IMAP server, it may take 20 seconds for it to remove the
message and re-create a big folder.  You don't want to wait 20 seconds
in general before saying "ok, we have a timeout and should reconnect".

So it would be fantastic if it was possible to do...  something...  to
make the following pseudo-code work:

(while (not done)
  (accept-process-output process 0 1)
  (when (and (absolutely-nothing-was-received)
             (> timeout two-seconds)
             (not (probe-for-connection-up)))
    (kill-process-and-reconnect process)
    (replay-commands)))

You get the drift.

So the problem is `probe-for-connection-up'.  Is there a general TCP way
to probe for a connection?  Can we (for instance) send a TCP KEEPALIVE
once and see whether we get anything back within (say) a second?

Or do something else that's clever?

-- 
(domestic pets only, the antidote for overdose, milk.)
  No Gnus T-Shirt for sale: http://ingebrigtsen.no/no.php




^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2013-08-13  1:52 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-03 12:30 Determining whether a TCP connection is up Lars Magne Ingebrigtsen
2013-08-03 14:09 ` Paul Eggert
2013-08-03 16:01 ` Julien Danjou
2013-08-05  2:12   ` Lars Magne Ingebrigtsen
2013-08-05  2:33     ` chad
2013-08-05  2:37       ` Lars Magne Ingebrigtsen
2013-08-05 10:34     ` Julien Danjou
2013-08-05 14:40       ` Stefan Monnier
2013-08-05 15:23         ` Thierry Volpiatto
2013-08-05 15:51         ` Julien Danjou
2013-08-05 17:55       ` Lars Magne Ingebrigtsen
2013-08-06  8:51         ` Julien Danjou
2013-08-06  9:59           ` joakim
2013-08-06 13:36           ` Lars Magne Ingebrigtsen
2013-08-06 21:32             ` Stefan Monnier
2013-08-12 17:09               ` Lars Magne Ingebrigtsen
2013-08-13  1:52                 ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.