From owner-freebsd-net@FreeBSD.ORG Thu Jul 20 02:51:31 2006 Return-Path: X-Original-To: net@freebsd.org Delivered-To: freebsd-net@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 14A1216A4DD for ; Thu, 20 Jul 2006 02:51:31 +0000 (UTC) (envelope-from dg@dglawrence.com) Received: from dglawrence.com (dsl-230-156.ipns.com [209.210.230.156]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8C6AB43D5F for ; Thu, 20 Jul 2006 02:51:30 +0000 (GMT) (envelope-from dg@dglawrence.com) Received: from tnn.dglawrence.com (localhost [127.0.0.1]) by dglawrence.com (8.13.6/8.13.3) with ESMTP id k6K2o4P8095931; Wed, 19 Jul 2006 19:50:04 -0700 (PDT) (envelope-from dg@dglawrence.com) Received: (from dg@localhost) by tnn.dglawrence.com (8.13.6/8.13.3/Submit) id k6K2o3Lt095910; Wed, 19 Jul 2006 19:50:03 -0700 (PDT) (envelope-from dg@dglawrence.com) X-Authentication-Warning: tnn.dglawrence.com: dg set sender to dg@dglawrence.com using -f Date: Wed, 19 Jul 2006 19:50:03 -0700 From: "David G. Lawrence" To: Mikhail Teterin Message-ID: <20060720025003.GF924@tnn.dglawrence.com> References: <200607192230.14939.mi+mx@aldan.algebra.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200607192230.14939.mi+mx@aldan.algebra.com> Cc: net@freebsd.org Subject: Re: complement to sendfile()? 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: Thu, 20 Jul 2006 02:51:31 -0000 > Hello! > > My program receives data from the socket and writes it to a file -- with the > usual read()/write() tedium. > > Is there anything zero-copying like sendfile() for the socket->file direction? > > In fact, sendfile's API may allow to use it in any direction, but the manual > is quite explicit, that the second (destination) argument must be socket. > > recvfile()? Thanks! sendfile() could be extended to allow arbitrary file descriptor types as the source and destination, but the zero-copy nature of it can only work in the file to socket direction. This is because network buffers can be made out of filesystem buffers (file->network direction), but for the network to file direction network packets arrive non-deterministically. With the right network hardware it would in theory be possible to have the TCP code run on the network card and it could DMA the TCP stream directly into file buffers. If pigs had wings, they could fly. :-) -DG David G. Lawrence President Download Technologies, Inc. - http://www.downloadtech.com - (866) 399 8500 The FreeBSD Project - http://www.freebsd.org Pave the road of life with opportunities.