From owner-freebsd-net@FreeBSD.ORG Wed Jan 31 20:40:22 2007 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 831A816A401; Wed, 31 Jan 2007 20:40:22 +0000 (UTC) (envelope-from wollman@khavrinen.csail.mit.edu) Received: from khavrinen.csail.mit.edu (khavrinen.csail.mit.edu [128.30.28.20]) by mx1.freebsd.org (Postfix) with ESMTP id 1217D13C461; Wed, 31 Jan 2007 20:40:21 +0000 (UTC) (envelope-from wollman@khavrinen.csail.mit.edu) Received: from khavrinen.csail.mit.edu (localhost.csail.mit.edu [127.0.0.1]) by khavrinen.csail.mit.edu (8.13.6/8.13.6) with ESMTP id l0VK4vhk066310 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK CN=khavrinen.csail.mit.edu issuer=Client+20CA); Wed, 31 Jan 2007 15:04:58 -0500 (EST) (envelope-from wollman@khavrinen.csail.mit.edu) Received: (from wollman@localhost) by khavrinen.csail.mit.edu (8.13.6/8.13.6/Submit) id l0VK4vXC066309; Wed, 31 Jan 2007 15:04:57 -0500 (EST) (envelope-from wollman) Date: Wed, 31 Jan 2007 15:04:57 -0500 (EST) From: Garrett Wollman Message-Id: <200701312004.l0VK4vXC066309@khavrinen.csail.mit.edu> To: freebsd@j-davis.com In-Reply-To: <1170269163.22436.71.camel@dogma.v10.wvs> Organization: MIT Computer Science & Artificial Intelligence Laboratory X-Greylist: Sender DNS name whitelisted, not delayed by milter-greylist-3.0 (khavrinen.csail.mit.edu [127.0.0.1]); Wed, 31 Jan 2007 15:04:58 -0500 (EST) Cc: freebsd-net@freebsd.org, freebsd-stable@freebsd.org Subject: Re: send() returns error even though data is sent, TCP connection still alive X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Jan 2007 20:40:22 -0000 In article <1170269163.22436.71.camel@dogma.v10.wvs>, Jeff Davis wrote: >You should see something like "write failed: host is down" and the >session will terminate. Of course, when ssh exits, the TCP connection >closes. The only way to see that it's still open and active is by >writing (or using) an application that ignores EHOSTDOWN errors from >write(). I agree that it's a bug. The only time write() on a stream socket should return the asynchronous error[1] is when the connection has been (or is in the process of being) torn down as a result of a subsequent timeout. POSIX says "may fail" for these errors write() and send() on sockets -GAWollman [1] There are two kinds of error returns in the socket model: synchronous errors, like synchronous signals, are attributed to the result of a specific system call, detected prior to syscall return, and usually represent programming or user error (e.g., attempting to connect() on an fd that is not a socket). Asynchronous errors are detected asynchronously, and merely posted to the socket without being delivered; they may be delivered on the next socket operation. See XSH 2.10.10, "Pending Error".