The writev callable service writes data from a set of buffers.
Operation | Environment |
---|---|
Authorization: | Supervisor state or problem state, any PSW key |
Dispatchable unit mode: | Task SRB - AF_INET/AF_INET6 socket support only |
Cross memory mode: | PASN = HASN |
AMODE (BPX1WRV): | 31-bit task or SRB mode |
AMODE (BPX4WRV): | 64-bit task mode only |
ASC mode: | Primary mode |
Interrupt status: | Enabled for interrupts |
Locks: | Unlocked |
Control parameters: | All parameters must be addressable by the caller and in the primary address space. |
|
AMODE 64 callers use BPX4WRV with the same parameters. All addresses in the Iov_struct structure are doublewords.
The name of a fullword that contains the file descriptor for which the writev is to be done.
The name of a field that contains the number of buffers that are pointed to by Iov_struct. The total number of buffers may not exceed IOV_MAX (defined in BPXYIOV — Map the I/O vector structure).
The name of a field that contains 31(64)-bit pointers to buffers from which data is to be retrieved for the purpose of writing to the file or socket. In 64-bit mode, Iov_struct contains doubleword pointer and length subfields. See BPXYIOV — Map the I/O vector structure for more information about the format of this field.
The name of a field that contains the ALET for Iov_struct.
The name of a field that contains the ALET for buffers that are pointed to by Iov_struct.
Return_code | Explanation |
---|---|
EBADF | An incorrect file descriptor was specified. The following reason codes can accompany the return code: JRFileDesNotInUse, JRFileNotOpen. |
ECONNRESET | Connection reset by peer. The following reason code can accompany the return code: JRSocketNotCon. |
EFBIG | Writing to the specified file would exceed either the file size limit for the process, or the maximum file size supported by the physical file system. |
EINTR | A signal interrupted the writev service before any data was written. The following reason code can accompany the return code: JRSockRdwrSignal. |
EINVAL | An incorrect value was specified on one of the input parameters. The following reason code can accompany the return code: JRSocketCallParmError. |
EIO | The process is in a background process group and is attempting to write to its controlling terminal. However, TOSTOP is set, the process is neither ignoring nor blocking SIGTTOU signals, and the process group of the process is orphaned. This can happen, for example, if a background job tries to write to the terminal after the user has logged off. |
EMSGSIZE | The message is too large to be sent all at once, as the socket requires. The following reason code can accompany the return code: JRSockBufMax. |
ENOBUFS | A buffer could not be obtained. The following reason code can accompany the return code: JROutofSocketCells. |
ENOTCONN | The socket was not connected. The following reason code can accompany the return code: JRSocketNotCon. |
ENOTSOCK | Socket_descriptor does not refer to a valid socket descriptor. The following reason code can accompany the return code: JRMustBeSocket. |
EPIPE | An attempt was made to write to a socket that is shut down
or closed. The following reason code can accompany the return code:
JRSocketClosed. This error also generates a SIGPIPE signal. |
EPROTOTYPE | An incorrect socket type was supplied. The following reason code can accompany the return code: JRIncorrectSocketType. |
EWOULDBLOCK |
The following reason codes can accompany the return code: JRTimeout, JRWouldBlock. |
The name of a fullword in which the writev service stores the reason code. The writev service returns Reason_code only if Return_value is -1. Reason_code further qualifies the Return_code value. For the reason codes, see z/OS UNIX System Services Messages and Codes.
The number of bytes that are requested for writing is checked against the file size limit for the process. If no data can be written without exceeding this limit, an error of EFBIG is returned and the SIGXFSZ signal is generated for the process. If at least one byte can be written before exceeding the file size limit, the write is considered successful.
If the file descriptor refers to a file on which you cannot seek, the service begins writing at the current position. No file offset is associated with such a file.
If the file was opened with the "append" option, the write routine sets the file offset to the end of the file before writing output.
If the write count that you specify is greater than the remaining space on the output device, or greater than the file size limit for the process, fewer bytes than you requested are written. When at least 1 byte is written, the write is considered successful. If you are not using a pseudoterminal, an attempt to append to the same file causes an error. An error of ENOSPC is returned when there is no remaining space on the output device. An error of EFBIG is returned when the file size limit for the physical file system is exceeded. An error of EFBIG is also returned if the file size limit for the process is exceeded, at which time the write service also generates a SIGXFSZ signal for the process. With a pseudoterminal, if there is not enough room in the buffer for the whole write, the number of bytes that fit are written, and the number of bytes that were written is returned. However, on the next write (assuming the buffer is still full) there is a block or EAGAIN is returned, depending on whether the file was opened blocking or nonblocking.
Similarly, fewer bytes are written if the service is interrupted by a signal after some, but not all, of the specified number of bytes are written. The return value shows the number of bytes that were written. But if no bytes were written before the routine was interrupted, the return value is -1 and an EINTR error is reported.
There are no restrictions on the use of the writev service.
For an example using this callable service, see BPX1WRV (writev) example.