Subject: Re: uvm and/vs splice() (was: re: Ongoing projects)
To: Todd Vierling <tv@pobox.com>
From: Chris G. Demetriou <cgd@netbsd.org>
List: tech-kern
Date: 05/07/1999 19:47:58
Todd Vierling <tv@pobox.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
bidirectional.

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
like:

	foo(to_fd, pre_iovec, from_fd, from_len, post_iovec)

where you forward:

	pre_iovec's data
	from_len bytes from from_fd
	post_iovec's data

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.



cgd
-- 
Chris Demetriou - cgd@netbsd.org - http://www.netbsd.org/People/Pages/cgd.html
Disclaimer: Not speaking for NetBSD, just expressing my own opinion.