NAME | SYNOPSIS | API RESTRICTIONS | FEATURES | DESCRIPTION | RETURN VALUES | ERRORS | ATTRIBUTES | SEE ALSO
#include <sys/types.h> #include <sys/socket.h>ssize_t send(int s, const char * msg, int len, int flags);
The fun ction or functions documented here may not be used safely in all application contexts with all APIs provided in the ChorusOS 5.0 product.
See API(5FEA) for details.
POSIX_SOCKETS
The send , sendto , and sendmsg system calls are used to transmit a message to another socket. The send call may only be used when the socket is in a connected state, while sendto and sendmsg may be used at any time.
The address of the target is given by to , with tolen specifying its size. The length of the message is given by len . If the message is too long to pass atomically through the underlying protocol, the error EMSGSIZE is returned, and the message is not transmitted.
No indication of failure to deliver is implicit in a send . Return values of -1 indicate locally detected errors.
If no message space is available at the socket to hold the message to be transmitted, send normally blocks, unless the socket has been placed in non-blocking I/O mode. The select (2POSIX) call may be used to determine when it is possible to send more data.
The flags parameter may include one or more of the following:
#define MSG_OOB 0x1 /* process out-of-band data */ #define MSG_DONTROUTE 0x4 /* bypass routing, use direct interface */ |
The flag MSG_OOB is used to send "out-of-band" data on sockets that support this concept (for example, SOCK_STREAM);the underlying protocol must also support "out-of-band" data. The MSG_DONTROUTE option is usually used only by diagnostic or routing programs.
See recv (2POSIX) for a description of the msghdr structure.
Upon successful completion, these calls return the number of bytes sent; otherwise they return -1 and set errno to indicate one of the following error conditions.
An invalid descriptor was specified.
The system call is invoked on a connection-less socket which has not been connected previously to a peer address.
The s argument is not a socket.
An invalid user address space was specified for a parameter.
The length argument has a negative value.
The socket requires messages to be sent atomically, and the size of the message to be sent made this impossible.
The socket is marked non-blocking and the operation requested would block.
The system was unable to allocate an internal buffer. The operation may succeed when buffers become available.
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.
sendto , or sendmsg are invoked on a non-connected TCP socket.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
MT-level | MT-safe |
NAME | SYNOPSIS | API RESTRICTIONS | FEATURES | DESCRIPTION | RETURN VALUES | ERRORS | ATTRIBUTES | SEE ALSO