Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

System Functions (s and S) sendmsg(2)
If the sending socket has no space to hold the message to be transmitted and the socket’s file
descriptor is blocking (O_NONBLOCK is not set), the sendmsg( ) function blocks until space is
available. If the sending socket has no space to hold the message to be transmitted and the
socket’s file descriptor is marked nonblocking (O_NONBLOCK is set), the sendmsg() function
fails and sets errno to [EWOULDBLOCK].
In the msghdr structure, the msg_control and msg_controllen members specify the ancillary
data buffer that can be used only by sockets in the AF_UNIX domain to pass file descriptors to
another process on the same node. The msg_control member can be a null pointer if ancillary
data is not desired or required. If the msg_control member is nonnull, it points to an ancillary
data buffer consisting of a cmsghdr structure followed by one to sixteen file descriptors. The
msg_controllen member specifies the size of the ancillary data buffer.
If sendmsg() is called with an ancillary data buffer, the members of the cmsghdr structure must
be set as follows:
The cmsg_level member must be set to SOL_SOCKET.
The cmsg_type member must be set to SCM_RIGHTS.
The value of the cmsg_len member must be equal to the value of the msg_controllen
member of the msghdr structure.
To pass a 32-bit pointer from a 32-bit Guardian or OSS client, sendmsg() must be called.
To pass a 64-bit pointer from a 32-bit Guardian or OSS client, sendmsg64_() must be called.
To pass a 32-bit pointer from a 64-bit OSS client, sendmsg() must be called.
To pass a 64-bit pointer from a 64-bit OSS client, sendmsg_() must be called.
NOTES
This function requires that the feature-test macro _XOPEN_SOURCE_EXTENDED be specified
when you compile the module.
When data can be sent, a call to the select() function indicates that the file descriptor for the
socket is ready for writing.
For systems running AF_UNIX Release 2 software:
Sockets created in compatibility mode can communicate with each other but cannot
communicate with sockets in portability mode.
Sockets created in portability mode can communicate with each other but cannot com-
municate with sockets created in compatibility mode.
For J06.07 and later J-series RVUs and H06.18 and later H-series RVUs, if a memory resource
allocation error occurs while attempting this operation, the operation succeeds but the resulting
file descriptor is not usable. All subsequent file operations that attempt to use the file descriptor
fail with the error [EBADF].
To use the sendmsg() functionality in a threaded application that uses the Standard POSIX
Threads library, see spt_sendmsgx(2).
To use this function in a threaded application that uses the POSIX User Thread Model library on
systems running J06.10 or later RVUs or H06.21 or later RVUs, you must perform all of the fol-
lowing tasks to make the function thread-aware in a multi-threaded application:
Compile the application using the _PUT_MODEL_ feature test macro or equivalent
compiler command option.
527186-023 Hewlett-Packard Company 735