z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


writev()

z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
SC27-3660-00

The writev() call writes data from a set of buffers on a socket using descriptor s.

The writev() call applies only to connected sockets.

#include <manifest.h>
#include <socket.h>
#include <bsdtypes.h>
#include <uio.h>
 
int writev(int s, struct iovec *iov, int iovcnt)
Parameter
Description
s
Socket descriptor.
iov
Points to an array of iovec buffers.
iovcnt
Number of buffers in the array.
The data is gathered from the buffers specified by iov[0]…iov[iovcnt-1]. The iovec structure is defined in UIO.H and contains the following fields:
Parameter
Description
iov_base
Points to the buffer.
iov_len
The length of the buffer.

This call writes the sum of the iov_len bytes of data.

If buffer space is not available to hold the socket data to be transmitted and the socket is in blocking mode, writev() blocks the caller until additional buffer space becomes available. If the socket is in a nonblocking mode, writev() returns a -1 and sets errno to EWOULDBLOCK. For a description of how to set nonblocking mode, see fcntl() or ioctl().

For datagram sockets, this call sends the entire datagram, providing the datagram can fit into the TCP/IP buffers. Stream sockets act like streams of information with no boundaries separating data. For example, if an application wants to send 1000 bytes, each call to this function can send 1 byte, or 10 bytes, or the entire 1000 bytes. Therefore, applications using stream sockets should place this call in a loop, calling this function until all data has been sent.

Return values

If successful, the number of bytes written from the buffers is returned. The value -1 indicates an error. Errno identifies the specific error.
Errno
Description
EBADF
Indicates that s is not a valid socket descriptor.
EFAULT
Using the iov and iovcnt parameters would result in an attempt to access storage outside the caller address space.
ENOBUFS
Buffer space is not available to send the message.
EWOULDBLOCK
Indicates that s is in nonblocking mode and there is not enough space in TCP⁄IP to accept the data.

Related calls

connect(), fcntl(), getsockopt(), ioctl(), write(), read(), readv(), recv(), recvmsg(), recvfrom(), select(), selectex(), send(), sendmsg(), sendto(), setsockopt(), socket(), write()

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014