SEND(2,L) AIX Technical Reference SEND(2,L)
-------------------------------------------------------------------------------
send, sendto, sendmsg
PURPOSE
Sends a message from a socket.
SYNTAX
#include <sys/types.h>
#include <sys/socket.h>
int send (s, msg, len, flags) int sendto (s, msg, len, flags, to, tolen)
int s; int s;
char *msg; char *msg;
int len, flags; int len, flags;
struct sockaddr *to;
int sendmsg (s, msg, flags) int tolen;
int s;
struct msghdr msg [ ];
int flags;
DESCRIPTION
The send system call sends a message only when the socket is in a connected
state. The sendto and sendmsg system calls can be used at any time.
Give the address of the target with to, specifying its size with tolen.
Specify the length of the message with len. Specify the socket ID as returned
by the socket system call with s. If the message is too long to pass through
the underlying protocol, the error EMSGSIZE is returned and the message is not
transmitted.
No indication of failure to deliver is implied in a send. Return values of -1
indicate some locally detected errors.
If no space for messages is available at the sending socket to hold the message
to be transmitted, the send system call blocks unless the socket is in a
nonblocking I/O mode.
Use the select system call to determine when it is possible to send more data.
The flags argument to send a call is formed by logically ORing one or both of
the values shown in the following list:
Processed November 7, 1990 SEND(2,L) 1
SEND(2,L) AIX Technical Reference SEND(2,L)
MSG_OOB Processes out-of-band data on sockets that support this notion,
for instance, SOCK_STREAM. The underlying protocol must also
support out-of-band data.
MSG_DONTROUTE Sends without using routing tables; this is usually used only
by diagnostic or routing programs.
For a description of the msghdr structure, see "recv, recvfrom, recvmsg." If
the Transparent Computing Facility is installed, processes using socket-related
system calls are limited to operating on a single cluster site.
RETURN VALUE
Upon successful completion, the number of characters sent is returned. If the
send, sendto, or sendmsg system call fails, a value of -1 is returned, and
errno is set to indicate the error. A socket marked with the O_NDELAY flag
returns ZERO in the situation where it would otherwise have blocked.
ERROR CONDITIONS
The system call fails if one or more of the following are true:
EBADF The s parameter is not valid.
ENOTSOCK The s parameter refers to a file, not a socket.
EFAULT The addr parameter is not in a readable part of the user address
space.
EMSGSIZE The socket requires that the message be sent all at once, and the
message is too large for that to happen.
EAGAIN The socket is marked nonblocking with the O_NONBLOCK flag or the
FIONBIO ioctl in the situation where it would otherwise have blocked.
ENOBUFS The system was unable to allocate an internal buffer. The operation
may succeed when buffers become available.
ENOBUFS The output queue for a network interface was full. This generally
indicates that the interface has stopped sending, but may be caused
by transient congestion.
RELATED INFORMATION
In this book: "recv, recvfrom, recvmsg" and "socket."
Processed November 7, 1990 SEND(2,L) 2