Writes bytes from a buffer to a file or socket. The $QIO equivalent is the IO$_WRITEVBLK function. Format #include <unixio.h> int write ( int d, void *buffer, int nbytes );
1 – Arguments
d A descriptor that refers to a socket or file. buffer The address of a buffer from which the output data is to be taken. nbytes The maximum number of bytes involved in the write operation.
2 – Description
This function attempts to write a buffer of data to a socket or file. Related Functions See also socket().
3 – Return Values
x The number of bytes written to the socket or file. -1 Error; errno is set to indicate the error.
4 – Errors
EPIPE The socket is shut down for writing or is connection oriented, and the peer is closed or shut down for reading. In the latter case, if the socket is of type SOCK_STREAM, the SIGPIPE signal is generated to the calling process. EWOULDBLOCK The NBIO (nonblocking) flag is set for the socket descriptor, and the process is delayed during the write operation. EINVAL The nbytes argument is a negative value. EAGAIN The O_NONBLOCK flag is set on this file, and the process is delayed in the write operation. EBADF The d argument does not specify a valid file descriptor that is open for writing. EINTR A write() function on a pipe is interrupted by a signal, and no bytes have been transferred through the pipe. EINVAL On of the following errors occurred: o The STREAM or multiplexer referenced by d is linked (directly or indirectly) downstream from a multiplexer. o The file position pointer associated with the d argument was a negative value. EPERM An attempt was made to write to a socket of type SOCK_STREAM that is not connected to a peer socket. EPIPE An attempt was made to write to a pipe that has only one end open. An attempt was made to write to a pipe or FIFO that is not opened for reading by any process. A SIGPIPE signal is sent to the process. ERANGE An attempt was made to write to a STREAM socket where the value of nbytes is outside the specified minimum and maximum range, and the minimum value is nonzero.