Sends messages from a connected socket.
Standard C Library (libc.a)
#include <sys/types.h> #include <sys/socketvar.h> #include <sys/socket.h>
int send (Socket,
Message, Length, Flags)
int Socket;
const void * Message;
size_t Length;
int Flags;
The send subroutine sends a message only when the socket is connected. This subroutine on a socket is not thread safe. The sendto and sendmsg subroutines can be used with unconnected or connected sockets.
To broadcast on a socket, first issue a setsockopt subroutine using the SO_BROADCAST option to gain broadcast permissions.
Specify the length of the message with the Length parameter. If the message is too long to pass through the underlying protocol, the system returns an error and does not transmit the message.
No indication of failure to deliver is implied in a send subroutine. A return value of -1 indicates some locally detected errors.
If no space for messages is available at the sending socket to hold the message to be transmitted, the send subroutine blocks unless the socket is in a nonblocking I/O mode. Use the select subroutine to determine when it is possible to send more data.
The socket applications can be compiled with COMPAT_43 defined. This will make the sockaddr structure BSD 4.3 compatible. For more details refer to socket.h.
Socket | Specifies the unique name for the socket. |
Message | Points to the address of the message to send. |
Length | Specifies the length of the message in bytes. |
Flags | Allows the sender to control the transmission of the message. The Flags parameter used to send a call is formed by logically
ORing one or both of the values shown in the following list:
|
Upon successful completion, the send subroutine returns the number of characters sent.
If the send subroutine is unsuccessful, the subroutine handler performs the following functions:
The subroutine is unsuccessful if any of the following errors occurs:
The connect subroutine, getsockopt subroutine, recv subroutine, recvfrom subroutine, recvmsg subroutine, select subroutine, sendmsg subroutine, sendto subroutine, setsockopt subroutine. shutdown subroutine, socket subroutine.
Sockets Overview and Understanding Socket Data Transfer in AIX 5L Version 5.2 Communications Programming Concepts.