Sends a message from a socket using a message structure.
Standard C Library (libc.a)
#include <sys/types.h> #include <sys/socketvar.h> #include <sys/socket.h>
int sendmsg ( Socket, Message, Flags)
const struct msghdr Message [ ];
The sendmsg subroutine sends messages through connected or unconnected sockets using the msghdr message structure. The /usr/include/sys/socket.h file contains the msghdr structure and defines the structure members. In BSD 4.4, the size and members of the msghdr message structure have been modified. Applications wanting to start the old structure need to compile with COMPAT_43 defined. The default behaviour is that of BSD 4.4.
To broadcast on a socket, the application program must first issue a setsockopt subroutine using the SO_BROADCAST option to gain broadcast permissions.
The sendmsg subroutine supports only 15 message elements.
|Socket||Specifies the socket descriptor.|
|Message||Points to the msghdr message structure containing the message to be sent.|
|Flags||Allows the sender to control the message transmission. The
sys/socket.h file contains the Flags
parameter. The Flags parameter used to send a call is formed
by logically ORing one or both of the following values:
Note: The following value is not for general use. It is an administrative tool used for debugging or for routing programs.
Upon successful completion, the sendmsg subroutine returns the number of characters sent.
If the sendmsg subroutine is unsuccessful, the system handler performs the following functions:
The sendmsg 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.|
|EWOULDBLOCK||The socket is marked nonblocking, and no connections are present to be accepted.|
The sendmsg subroutine is part of Base Operating System (BOS) Runtime.
All applications containing the sendmsg subroutine must be compiled with _BSD set to a specific value. Acceptable values are 43 and 44. In addition, all socket applications must include the BSD libbsd.a library.
The no command.
The connect subroutine, getsockopt subroutine, recv subroutine, recvfrom subroutine, recvmsg subroutine, select subroutine, send subroutine, sendto subroutine, setsockopt subroutine. shutdown subroutine, socket subroutine.
Sockets Overview and Understanding Socket Data Transfer in AIX 5L Version 5.1 Communications Programming Concepts.