Writes data from a user buffer to a socket.
#include <sys/socket.h> ssize_t send ( int s, const void *msg, size_t len, int flags);
(IN) Specifies the socket file handle of a socket to which the data is to be written.
(IN) Points to the message to be sent.
(IN) Specifies the length of the message.
(IN) Specifies the type of message transmission. See Message Types.
If successful, returns the number of characters sent. Otherwise, returns -1 and sets errno to one of the following:
The send function is used only with connected sockets, because no destination address can be specified.
The function can be used on SOCK_STREAM sockets. When called on a blocking SOCK_STREAM socket, the function blocks until all of the client’s data can be sent or buffered by the socket. When called on a nonblocking socket, the function sends or buffers the maximum amount of data that can be handled without blocking and returns the amount that was taken. If no data is taken, it returns -1, indicating an EWOULDBLOCK error.
A successful completion of a call to send does not guarantee delivery of the message. A return value of -1 only indicates locally detected errors.
If the local socket lacks buffer space to hold the message to be transmitted, send usually blocks unless the socket has been placed in nonblocking I/O mode. The select function can called used to determine when it is possible to send more data.
Only TCP sockets support out-of-band transmission (accomplished by placing a new urgent boundary just before the last byte of the sent message).
If the message is too long to pass atomically through the underlying protocol, EMSGSIZE is returned in errno, and the message is not transmitted.