From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lars Magne Ingebrigtsen Newsgroups: gmane.emacs.devel Subject: Determining whether a TCP connection is up Date: Sat, 03 Aug 2013 14:30:33 +0200 Organization: Programmerer Ingebrigtsen Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1375533066 26966 80.91.229.3 (3 Aug 2013 12:31:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 3 Aug 2013 12:31:06 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 03 14:31:08 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1V5azC-0005EB-Q7 for ged-emacs-devel@m.gmane.org; Sat, 03 Aug 2013 14:31:07 +0200 Original-Received: from localhost ([::1]:43432 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V5azC-00046H-Eb for ged-emacs-devel@m.gmane.org; Sat, 03 Aug 2013 08:31:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57702) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V5az2-000467-Ig for emacs-devel@gnu.org; Sat, 03 Aug 2013 08:31:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V5ayw-00035n-Dk for emacs-devel@gnu.org; Sat, 03 Aug 2013 08:30:56 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:33796) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V5ayw-00035b-6V for emacs-devel@gnu.org; Sat, 03 Aug 2013 08:30:50 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1V5ayo-0004DH-Oz for emacs-devel@gnu.org; Sat, 03 Aug 2013 14:30:42 +0200 Original-Received: from cm-84.215.51.58.getinternet.no ([84.215.51.58]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 03 Aug 2013 14:30:42 +0200 Original-Received: from larsi by cm-84.215.51.58.getinternet.no with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 03 Aug 2013 14:30:42 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-Lines: 47 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: cm-84.215.51.58.getinternet.no Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEWCQzeRTkKgXld1OC+0 oKs9FhRmLSOJhUueAAACYklEQVQ4jUXTwXLbIBAG4MUkPgNyfDZrtWdJNNxLmZw79aCzE1W8/yP0 X2S5zNij4dMusKyoZ6OV87paWksJx1K+cj7kTNZ5xcyXeGe26wz4k2UQJh1+3AW4CbqU2xPYg656 sNaSXsv0BC9/F7LKWBNWWUMg52QOADsyIgRqv0FiJM+YBQLea33ZgFkC2HnkBAzaPsG9fTKT7xML kO134ISXJ4983oSg/QaJH8NuoMhj2R7wEA9I3mi2Lv+P6GVXrm9gTvsBvezUGywqqfja74BzOcyT 4gZd3gE7IaNDaKCN3uESl7DEWpexRcT6SJW6u+zVH+vgJDrW7UaIj2NKmZM/Lg3q31/zqYEeU859 yh8bxB/7GnqN3/P08/K2HNoaeYdBAhH0TUDX8oRAqT1dq8D71gtrIe7aBWIuHtBJoTwG8VkZ5Yzv hnjwJubXNo3q8nW0ODYuqCpPASnL1G8lueOq7UB6sVbXKT8X5zOKiEoe79bEtcwvT7iMJi5kogQg /fwl532VXuvQaKRHSwjAqFOSXcleJ/ZqwF5lfkad+Q1wd62xBtQp4u02HJee5lHaXbqtW3f4lC4p S+tBBBxbHhkLO0AZLwI6bAEBV1XZ9lTLHCTP6F8FUAOIsgeqa7k5HE3Z8w4hKhNoqeVmbTejLoAl DChOGEKkENcb3r7tQANBQhWY8fgbUWgigIxQV6pVgARClVQkEbUIFGXNp4BESIg0VwOyZhQY0JT4 1rDCDoYUih7ccdm2uwPCBQbXBZHaXt5AyTc+KJe2YuHCNlBWvnFSp3R+zG+wNLBkT+laW6JS/gHD et6YVBwEDwAAAABJRU5ErkJggg== Mail-Copies-To: never X-Now-Playing: Arto Lindsay's _O Corpo Sutil_: "My Mind is Going" User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:1jeZJhzc0iecdH/OMRuBhqN7+xc= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:162401 Archived-At: 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