Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jul 2006 19:50:03 -0700
From:      "David G. Lawrence" <dg@dglawrence.com>
To:        Mikhail Teterin <mi+mx@aldan.algebra.com>
Cc:        net@freebsd.org
Subject:   Re: complement to sendfile()?
Message-ID:  <20060720025003.GF924@tnn.dglawrence.com>
In-Reply-To: <200607192230.14939.mi%2Bmx@aldan.algebra.com>
References:  <200607192230.14939.mi%2Bmx@aldan.algebra.com>

next in thread | previous in thread | raw e-mail | index | archive | help
> 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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060720025003.GF924>