when to use readv()/writev() ?
Marcus J. Ranum
mjr at decuac.dec.com
Thu Nov 8 15:13:57 AEST 1990
What are some cases when I'd want to use readv() instead of
read()? I understand the advantages of being able to break things
into several buffers (and possibly avoid having to move data around)
but does using writev() give me some kind of possible performance
improvement? Does writev() help block my data into popular buffer
sizes or something like that ?
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?
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()? Please let's
*NOT* get into a bOring 6-week long discussion about checking return
values. Suffice to say I do. :)
mjr.
More information about the Comp.unix.programmer
mailing list