Subject: Re: uvm and/vs splice() (was: re: Ongoing projects)
To: Todd Vierling <email@example.com>
From: Chris G. Demetriou <firstname.lastname@example.org>
Date: 05/07/1999 19:47:58
Todd Vierling <email@example.com> writes:
> : splice() takes two unrelated descriptors (say, d1 and d2) and connects them...
> : what would otherwise be read(d1)able from the first, is instead move to d2 as if
> : somebody would read(d1, buffer) and write(d2, buffer) in a loop.
> : right. except not as a 'pipe' -- data flows both directions.
> So it's the opposite of socketpair() instead of pipe(). :)
For many real-world proxy applications, unidirectional is nicer than
it's often nice to do something like:
A sends request to B (proxy)
B reads and interprets request, forwards it to server C
along with a fixed amount of data.
C sends response to B.
B reads and interprets request, forwards it to client A
along with data.
To express the logical operation you want, you really want something
foo(to_fd, pre_iovec, from_fd, from_len, post_iovec)
where you forward:
from_len bytes from from_fd
to the destination described by to_fd. If there's no badness re:
underlying network protocols, etc., then you could do this with a
write/writev, then a 'splice-ish' call, then another write/writev.
Chris Demetriou - firstname.lastname@example.org - http://www.netbsd.org/People/Pages/cgd.html
Disclaimer: Not speaking for NetBSD, just expressing my own opinion.