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. 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.
|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:
|EBADF||The Socket parameter is not valid.|
|ENOTSOCK||The Socket parameter refers to a file, not a socket.|
|EFAULT||The Address parameter is not in a writable part of the user address space.|
|EWOULDBLOCK||The socket is marked nonblocking, and no connections are present to be accepted.|
The send subroutine is part of Base Operating System (BOS) Runtime.
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.
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 Version 4.3 Communications Programming Concepts.