1READV(2)                   Linux Programmer's Manual                  READV(2)
2
3
4

NAME

6       readv, writev - read or write data into multiple buffers
7

SYNOPSIS

9       #include <sys/uio.h>
10
11       ssize_t readv(int fd, const struct iovec *vector, int count);
12
13       ssize_t writev(int fd, const struct iovec *vector, int count);
14

DESCRIPTION

16       The  readv()  function reads count blocks from the file associated with
17       the file descriptor fd into the multiple buffers described by vector.
18
19       The writev() function writes at most count blocks described  by  vector
20       to the file associated with the file descriptor fd.
21
22       The pointer vector points to a struct iovec defined in <sys/uio.h> as
23
24         struct iovec {
25             void *iov_base;   /* Starting address */
26             size_t iov_len;   /* Number of bytes */
27         };
28
29       Buffers are processed in the order specified.
30
31       The  readv() function works just like read(2) except that multiple buf‐
32       fers are filled.
33
34       The writev() function works just like  write(2)  except  that  multiple
35       buffers are written out.
36

RETURN VALUE

38       On  success, the readv() function returns the number of bytes read; the
39       writev() function returns the number of bytes written.  On error, -1 is
40       returned, and errno is set appropriately.
41

ERRORS

43       The  errors  are  as  given for read(2) and write(2).  Additionally the
44       following error is defined:
45
46       EINVAL The sum of the iov_len values overflows an  ssize_t  value.  Or,
47              the  vector  count  count  is less than zero or greater than the
48              permitted maximum.
49

CONFORMING TO

51       4.4BSD (the readv() and writev() functions first appeared  in  4.2BSD),
52       POSIX.1-2001.  Linux libc5 used size_t as the type of the count parame‐
53       ter, and int as return type for these functions.
54

LINUX NOTES

56       POSIX.1-2001 allows an implementation to place a limit on the number of
57       items  that  can  be passed in vector.  An implementation can advertise
58       its limit by defining IOV_MAX in <limits.h> or  at  run  time  via  the
59       return value from sysconf(_SC_IOV_MAX).  On Linux, the limit advertised
60       by these mechanisms is 1024, which is the true kernel limit.   However,
61       the  glibc wrapper functions do some extra work if they detect that the
62       underlying kernel system call failed because this limit  was  exceeded.
63       In  the case of readv() the wrapper function allocates a temporary buf‐
64       fer large enough for all of the items specified by vector, passes  that
65       buffer  in  a  call to read(), copies data from the buffer to the loca‐
66       tions specified by the iov_base fields of the elements of  vector,  and
67       then  frees the buffer.  The wrapper function for writev() performs the
68       analogous task using a temporary buffer and a call to write().
69

BUGS

71       It is not advisable to mix calls to functions like readv() or writev(),
72       which  operate  on  file descriptors, with the functions from the stdio
73       library; the results will be undefined and probably not what you want.
74

SEE ALSO

76       read(2), write(2)
77
78
79
80                                  2002-10-17                          READV(2)
Impressum