Chapter Contents |
Previous |
Next |
readv |
Portability: | UNIX compatible |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
CAUTION | |
PORTABILITY | |
RELATED FUNCTIONS |
SYNOPSIS |
#include <sys/types.h> #include <sys/uio.h> #include <fcntl.h> int readv(int s, struct iovec *iov, int iovcnt);
DESCRIPTION |
readv
reads data from socket or file descriptor
s
into the
iovcnt
buffers specified by the
iov
array. As with the
read
call, the socket must have
been previously associated with a remote
address via the
connect
system call. If there are no data,
readv
blocks the caller unless the socket is in non-blocking mode.
The
iovec
structure is
defined in
<sys/uio.h>
.
Each
iovec
entry specifies
the base address and length of an area in memory in which the data should
be placed.
readv
completely
fills one area before proceeding to the next area.
Note:
Although
readv
is primarily
used with sockets, it can also be used to read any file that can be accessed
by the
read
function.
RETURN VALUE |
If
readv
succeeds, it returns the number of bytes read into the buffer.
If
readv
returns a
0
, the end-of-file has been reached.
If
readv
fails, it returns
a
-1
. It is common for
readv
to return a value less
than the total number of bytes in the buffers. This is not an error.
CAUTION |
readv
is an atomic operation. With UDP, no more than one datagram
can be read per call. If you are using datagram sockets, make sure that there
is enough buffer space in the I/O vector to contain an incoming datagram.
PORTABILITY |
readv
is portable to other environments, including most UNIX systems,
that implement BSD sockets.
RELATED FUNCTIONS |
connect
,
recv
,
recvfrom
,
recvmsg
,
write
,
writev
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.