writev

Finds

Library:LibC
Classification:BSD
Service:Networking

Syntax

  #include <sys/uio.h> 
   
  ssize_t writev (
     int                   fildes,
     const struct iovec   *iov,
     int                   iovcnt);
  

Parameters

fildes

(IN) Specifies the file handle from which data is to be written.

iov

(IN) Points to the iovec structure containing the base address and the length of an area in memory where data can be copied.

iovcnt

(IN) Specifies the number of buffers in the iov array.

Return Values

If successful, returns either 0 or the number of bytes actually written. Otherwise, returns -1 and sets errno to one of the following:

Decimal

Constant

Description

4

EBADF

The socket file handle is invalid for writing.

9

EINVAL

The socket is not in a listening state.

32

EPIPE

A write attempt was made to a SOCK_STREAM socket that is not connected to a peer socket or has been closed.

35

EWOULDBLOCK

The socket is marked nonblocking, and no connections are present to be accepted.

39

EDESTADDRREQ

The datagram socket has not associated itself with a destination address.

40

EMSGSIZE

On a SOCK_DGRAM socket, the size of the message would exceed the protocol’s capability.

Remarks

Each iovec entry specifies the base address and length of an area in memory from which data can be copied.

When calling nonblocking I/O on SOCK_STREAM sockets, writev might write fewer bytes than requested. Note the return value, call select to determine when to try the operation again, and retry the remainder of the operation.

The writev function can also write data to SOCK_DGRAM sockets, but send is usually called. The writev function is identical to a send request, except flags is not available.

See Also

send