Re: Linux Zero Copy

From: Jamie Lokier (
Date: Thu Aug 14 2003 - 11:59:01 EST

Nagendra Singh Tomar wrote:
> Why do we not have a recvfile() also which copies data from the socket
> directly to a file (page cache).

Mainly because it is much harder to do than sendfile().

Typically, each packet is DMAd from the network card to some place in
RAM before the kernel has an opportunity to look at the packet header.

To receive directly to the page cache, something would have to analyse
each packet header _before_ the data was transferred from the network
card, to decide where the data should go.

Among other things, this requires special hardware support, which is
more complex and rarer than the scatter-gather + checksum support used
by sendfile(), which many NICs have.

Eventually this might happen, for limited set of network cards
(possibly ones which don't exist yet), and it has been suggested that
async (aio) read or async recvfile is a good interface for this.

Another reason it is not done is that transmitting data is considered
more important on servers, which often transmit much more data than
they receive.

-- Jamie

To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at