tech-kern archive

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

Re: Equivalent of the system call sendfile



On Tue, Nov 25, 2008 at 07:43:06PM +0000, Wouter Klouwen wrote:
> kamel derouiche(kamelderouiche%yahoo.com@localhost) said 2008.11.25 08:37:29 
> +0000:
> > > Oops, you're right ... read() doesn't work. So:
> > > 
> > > mmap() the file - or a big portion of it
> > > 
> > > write() to the network.
> > 
> > There is a software that i want to ported on pkgsrc,
> > That last package uses sendfile system call. I need a
> > call system that corresponding to the that sendfile in netbsd
> 
> sendfile has the following arguments:
>       socket
>       file descriptor
>       offset
>       length
>       and some other guff.
> So, you can use:
>       void *addr = mmap(NULL, length, PROT_READ, MAP_FILE | MAP_SHARED,
>               file descriptor, offset);
>       send(socket, addr, length, 0);

Although you'd be better limiting the length of each mmap.
Otherwise you can run out of process VM for very large files.

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index