writev(2) CLIX writev(2)
NAME
writev - Writes output from scattered locations
LIBRARY
Berkeley Software Distribution Library (libbsd.a)
SYNOPSIS
#include <sys/types.h>
#include <sys/uio.h>
int writev(
int s ,
struct iovec *iov ,
int iovcnt );
PARAMETERS
s Represents a socket descriptor.
iov Points to an array of buffers containing the data to be written.
iovcnt Specifies the number of buffers pointed to by iov.
DESCRIPTION
The writev() function attempts to write data to the object referenced by
the descriptor s. The output data is gathered from 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 from which data should be written. The writev() function will
always write a complete area before proceeding to the next.
When using nonblocking I/O, writev() may write fewer bytes than requested;
the return value must be noted and the remainder of the operation should
be retried when possible.
EXAMPLES
2/94 - Intergraph Corporation 1
writev(2) CLIX writev(2)
To write data to socket sd:
if (writev(sd, iov, iovcnt) == -1)
perror("Writev failed");
CAUTIONS
The writev() function does not work on regular files; it is usable only
with sockets.
RETURN VALUES
Upon successful completion, the number of bytes written is returned.
Otherwise, a value of -1 is returned and errno is set to indicate the
error.
ERRORS
The writev() 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 writev() function.
[EFAULT]
An invalid user space address was specified.
[EPIPE]
The socket was disconnected or shutdown for writing.
[EINVAL]
The maximum number of scatter gather locations was exceeded.
[ENOTCONN]
An attempt was made to send data on a stream socket that is not
connected.
[EDESTADDRREQ]
An attempt was maded to send data on a datagram socket without a
destination address.
2 Intergraph Corporation - 2/94
writev(2) CLIX writev(2)
[EISCONN]
An attempt was made to perform a sendto() on a connected socket.
RELATED INFORMATION
Functions: fcntl(2), recv(2), writev(2), select(2), getsockopt(2),
socket(2)
2/94 - Intergraph Corporation 3