readv(2) CLIX readv(2)
NAME
readv - Reads input into scattered locations
LIBRARY
Berkeley Software Distribution Library (libbsd.a)
SYNOPSIS
#include <sys/types.h>
#include <sys/uio.h>
int readv(
int s ,
struct iovec *iov ,
int iovcnt );
PARAMETERS
s Represents a socket descriptor.
iov Points to an array of buffers to store the data in.
iovcnt Specifies the number of input buffers.
DESCRIPTION
The readv() function attempts to read data from the object referenced by
the descriptor s. The input data is scattered into the iovcnt buffers
specified by the members of the iov array: iov[0], iov[1], ... ,
iov[iovcnt - 1]:
The iovec structure is defined as
struct iovec {
caddr_t iov_base;
int iov_len;
};
Each iovec entry specifies the base address and length of an area in
memory where data should be placed. The readv() function will always fill
an area completely before proceeding to the next.
If the returned value is 0, end-of-file has been reached.
EXAMPLES
To read an open socket from descriptor sd into buffers pointed to by iov:
if (readv(sd, iov, iovcnt) == -1)
2/94 - Intergraph Corporation 1
readv(2) CLIX readv(2)
perror("Readv failed");
NOTES
The readv() function is only supported on sockets, not on regular files.
RETURN VALUES
Upon successful completion, the number of bytes read is returned.
Otherwise, a value of -1 is returned and errno is set to indicate the
error.
ERRORS
The readv() function fails if one or more of the following is true:
[EBADF]
The descriptor is not valid.
[ENOTSOCK]
The descriptor references a file, not a socket.
[EWOULDBLOCK]
The socket is marked nonblocking and the requested operation would
block.
[EINTR]
A signal was caught during the readv() function.
[EFAULT]
The address specified is not in a valid part of the user's address
space.
[ECONNRESET]
The connection has been broken and there is no more data to read.
[EINVAL]
The maximum number of scatter gather locations has been exceeded.
RELATED INFORMATION
Functions: fcntl(2), read(2), send(2), select(2), getsockopt(2),
socket(2)
2 Intergraph Corporation - 2/94