when to use readv()/writev() ?

Chris Torek chris at mimsy.umd.edu
Thu Nov 8 17:55:05 AEST 1990


In article <1990Nov8.041357.29013 at decuac.dec.com> mjr at decuac.dec.com
(Marcus J. Ranum) writes:
>	If I have 2 iovecs with 500 and 524 bytes respectively is the
>operation performed analogous to write(fd,buf,1024) or is it simply
>write(fd,buf1,500), write(fd,buf2,524) with the kernel just doing
>the legwork?

The latter (except, potentially, to a character device, but there are
no character devices in any Unix I have seen that do anything special
with multiple IO vectors).

>	I see I still have to sum up the sizes of the contents of the
>scatter/gather arrays so I can check the return of the write - doesn't
>it get kind of icky when you have a partial writev()?

Yes, it does.  This is one of the reasons I elected not to use writev()
in my stdio implementation (which has a stdio-level writev-like function
whose main raison d'etre is printf()).
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.programmer mailing list