PROLOG |NAME |SYNOPSIS |DESCRIPTION |RETURN VALUE |ERRORS |EXAMPLES |APPLICATION USAGE |RATIONALE |FUTURE DIRECTIONS |SEE ALSO |COPYRIGHT | |
READV(3P) POSIX Programmer's ManualREADV(3P)This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
readv — read a vector
#include <sys/uio.h> ssize_t readv(intfildes, const struct iovec *iov, intiovcnt);
Thereadv() function shall be equivalent toread(), except as described below. Thereadv() function shall place the input data into theiovcnt buffers specified by the members of theiov array:iov[0],iov[1], ...,iov[iovcnt-1]. Theiovcnt argument is valid if greater than 0 and less than or equal to {IOV_MAX}. Eachiovec entry specifies the base address and length of an area in memory where data should be placed. Thereadv() function shall always fill an area completely before proceeding to the next. Upon successful completion,readv() shall mark for update the last data access timestamp of the file.Refer toread(3p).
Refer toread(3p). In addition, thereadv() function shall fail if:EINVALThe sum of theiov_len values in theiov array overflowed anssize_t. Thereadv() function may fail if:EINVALTheiovcnt argument was less than or equal to 0, or greater than {IOV_MAX}.The following sections are informative.Reading Data into an Array The following example reads data from the file associated with the file descriptorfd into the buffers specified by members of theiov array. #include <sys/types.h> #include <sys/uio.h> #include <unistd.h> ... ssize_t bytes_read; int fd; char buf0[20]; char buf1[30]; char buf2[40]; int iovcnt; struct iovec iov[3]; iov[0].iov_base = buf0; iov[0].iov_len = sizeof(buf0); iov[1].iov_base = buf1; iov[1].iov_len = sizeof(buf1); iov[2].iov_base = buf2; iov[2].iov_len = sizeof(buf2); ... iovcnt = sizeof(iov) / sizeof(struct iovec); bytes_read = readv(fd, iov, iovcnt); ...
None.
Refer toread(3p).
None.
read(3p),writev(3p) The Base Definitions volume of POSIX.1‐2017,sys_uio.h(0p)
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online athttp://www.opengroup.org/unix/online.html . Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, seehttps://www.kernel.org/doc/man-pages/reporting_bugs.html .IEEE/The Open Group 2017READV(3P)Pages that refer to this page:sys_uio.h(0p), read(3p), writev(3p)
HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface. For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere. Hosting byjambit GmbH. | ![]() |