gtpc1m4iTransmission Control Protocol/Internet Protocol

writev -- Write Data on a Connected Socket

The writev function writes data on a socket with descriptor s.

Format

#include    <socket.h>
int         writev(int s,
                   struct iovec *iov,
                   int iovcnt);

s
The socket descriptor.

iov
The pointer to an array of iovec buffers.

iovcnt
Number of buffers pointed to by the iov parameter.

Normal Return

If it succeeds, the function returns the number of bytes written from the buffer.

Error Return

A return code equal to -1 indicates an error. You can get the specific error code by calling sock_errno. See Appendix C, Socket Error Return Codes for more information about socket errors.

Note:
Unless otherwise stated in the description, the following error codes can be returned for either TCP/IP offload support or TCP/IP native stack support.

Value
Description

SOCFAULT
Using iov and iovcnt results in an attempt to access memory outside the caller's address space. This error code is returned only for TCP/IP offload support.

SOCNOBUFS
Buffer space is not available to send the message.

SOCNOTSOCK
The s parameter is not a valid socket descriptor.

SOCWOULDBLOCK
The s parameter is in nonblocking mode and no buffer space is available to hold the message to be sent.

SOCINVAL
The iovcnt parameter was not valid or one of the fields in the iov array was not valid.

SOCMSGSIZE
The message was too large to be sent. This error code is returned only for TCP/IP native stack support.

SOCNOTCONN
The socket is not connected.

EIBMIUCVERR
An error occurred when the function call was sent to the offload device. This error code is returned only for TCP/IP offload support.

E1052STATE
The socket was closed because the system was in or cycling down to 1052 state.

EINACT
An offload device associated with the socket descriptor has been disconnected. The socket is closed except in the following cases where the API function call must be reissued to determine if the socket is available:

This error code is returned only for TCP/IP offload support.

ESYSTEMERROR
A system error has occurred and closed the socket.

SOCTIMEDOUT
The operation timed out. The socket is still available. This error code is returned only for TCP/IP native stack support.

Programming Considerations

Examples

The following example sends data in two buffers of 10 bytes each.

#include <socket.h>

·
·
·
int bytes_sent; int server_sock; int wv_count; char msg1[10] = "aaaaa"; char msg2[10] = "bbbbb"; struct iovec wv[2];
·
·
·
wv[0].iov_base = msg1; wv[1].iov_base = msg2; wv[0].iov_len = sizeof(msg1); wv[1].iov_len = sizeof(msg2); wv_count = 2; bytes_sent = writev(server_sock,wv,wv_count);

Related Information