.\" Hey Emacs! This file is -*- nroff -*- source. .\" .\" Copyright (c) 1996 Tom Bjorkholm .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, write to the Free .\" Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, .\" USA. .\" .\" 1996-04-12 Tom Bjorkholm .\" First version written .\" Modified Tue Oct 22 17:41:07 1996 by Eric S. Raymond .\" .TH READV 2 "1996-04-12" "Linux 1.3.86" "Linux Programmer's Manual" .SH NAME readv, writev \- read or write a vector .SH SYNOPSIS .B #include .sp .BI "int readv(int " fd ", const struct iovec * " vector ", size_t " count ); .sp .BI "int writev(int " fd ", const struct iovec * " vector ", size_t " count ); .sp .B \fBstruct iovec {\fR .br \fB__ptr_t \fIiov_base\fB;\fR /* Starting address. */ .br \fBsize_t \fIiov_len\fB;\fR /* Length in bytes. */ .br \fB};\fR .fi .SH DESCRIPTION \fBreadv\fR reads data from file descriptor \fIfd\fR, and puts the result in the buffers described by \fIvector\fR. The number of buffers is specified by \fIcount\fR. The buffers are filled in the order specified. Operates just like \fBread\fR except that data is put in \fIvector\fR instead of a contiguous buffer. \fBwritev\fR writes data to file descriptor \fIfd\fR, and from the buffers described by \fIvector\fR. The number of buffers is specified by \fIcount\fR. The buffers are used in the order specified. Operates just like \fBwrite\fR except that data is taken from \fIvector\fR instead of a contiguous buffer. .SH RETURN VALUE On success \fBreadv\fR returns the number of bytes read. On success \fBwritev\fR returns the number of bytes written. On error, \-1 is returned, and \fIerrno\fR is set appropriately. .SH ERRORS .TP 0.8i .B EINVAL An invalid argument was given. For instance \fIcount\fR might be greater than \fBMAX_IOVEC\fR, or zero. \fIfd\fR could also be attached to an object which is unsuitable for reading (for \fBreadv\fR) or writing (for \fBwritev\fR). .TP .B EFAULT "Segmentation fault." Most likely \fIvector\fR or some of the \fIiov_base\fR pointers points to memory that is not properly allocated. .TP .B EBADF The file descriptor \fIfd\fR is not valid. .TP .B EINTR The call was interrupted by a signal before any data was read/written. .TP .B EAGAIN Non-blocking I/O has been selected using \fBO_NONBLOCK\fR and no data was immediately available for reading. (Or the file descriptor \fIfd\fR is for an object that is locked.) .TP .B EISDIR \fIfd\fR refers to a directory. .TP .B EOPNOTSUP \fIfd\fR refers to a socket or device that does not support reading/writing. .PP Other errors may occur, depending on the object connected to \fIfd\fR. .SH "CONFORMING TO" 4.4BSD (the .B readv and .B writev functions first appeared in BSD 4.2). .SH SEE ALSO .BR read (2), .BR write (2), .BR fprintf (3), .BR fscanf (3)