Saturday, February 18, 2012

readv writev

These functions are known as scatter read and write functions. They are designated that way because these functions can read into or write from many buffers in one atomic operation. The function prototypes for these functions are provided as follows:

#include <sys/uio.h>
int readv(int fd, const struct iovec *vector, int count);
int writev(int fd, const struct iovec *vector, int count);

These functions take three arguments, which are
  • The file descriptor fd to read or write upon. 
  • The I/O vector (vector) to use for reading or writing.
  • The number of vector elements (count) to use.
The return value for these functions are the number of bytes read for readv(2) or the number of bytes written for writev(2). If an error occurs, -1 is returned and errno holds the error code for the failure. Note that like other I/O functions, the error EINTR can be returned to indicate that it was interrupted by a signal.


See Also:

No comments:

Post a Comment