Re: Linux Zero Copy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nagendra Singh Tomar wrote:
>         Thanx for ur reply. So this means that this Zero Copy can only be 
> used by senders who have to send data from a "file" that supports mmap. I 
> just can't fill a buffer in userland and expect it to be sent via Zero 
> Copy. 

You can fill a buffer in userland and send it with zerocopy.  To do
this, mmap() a file using PROT_READ|PROT_WRITE and MAP_FILE|MAP_SHARED.

Then you can write directly to the file's pages in memory, and use
sendfile() to send that data.

You only have to set up a mapping once; after that, for each thing you
want to transmit just choose a region in the mapped memory to prepare
your data in, and call sendfile() to send it.

Ideally, you would use a shared memory file ("man shm_open"), but I
understand that with kernels prior to 2.4.22, that doesn't work with
sendfile(), so you have to use a real file for older kernels than that.

Enjoy,
-- Jamie
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux