write(2dn)
NAME
write − write or send data
SYNTAX
#include <sys/types.h>
#include <sys/socket.h>
cc = write (s,msg,msglen)
int cc,s;
char *msg;
int msglen;
ARGUMENTS
Input Arguments
s Specifies a descriptor for a socket that has been returned by the socket call.
msg Specifies the address of the buffer that contains the outgoing message.
msglen Specifies the size of the message.
Return Argument
cc Number of bytes sent.
DESCRIPTION
The write call is used to transmit normal data messages to another program. You can use write only when a socket is in a connected state. For further information, see connect(2dn).
The number of bytes sent is returned in cc. If no message space is available at the receiving socket to hold the message being transmitted, the write call most likely will block. If the socket is set in nonblocking I/O mode, the write returns in error with errno set to EWOULDBLOCK.
You can use the select call to determine when it is possible to send more data.
RETURN VALUE
If the call succeeds, the number of bytes actually written is returned. If an error occurs, a value of −1 is returned and errno is set to indicate the error.
DIAGNOSTICS
[EBADF] The s argument is not a valid descriptor open for writing.
[EPIPE] An attempt is made to write to a socket of the type SOCK_STREAM, which is not connected to a peer socket.
[EMSGSIZE] An attempt is made to transmit a zero-length message or a message that is larger than the DECnet pipeline quota on a stream or sequenced packet socket.
[EWOULDBLOCK] The socket is marked nonblocking and the write operation would have blocked.
[EFAULT] Part of s or data to be written to the file points outside the process’s allocated address space.