Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
System Functions (s and S) spt_sendmsgx(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 spt_sendmsgx() 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 spt_sendmsgx()
function fails and sets errno to [EWOULDBLOCK].
In the msghdr structure, the msg_control and msg_controllen members specify the ancillary
data buffer that only sockets in the AF_UNIX domain can use 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 1 to 16 file descriptors. The msg_controllen
member specifies the size of the ancillary data buffer.
If spt_sendmsgx() 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.
NOTES
The macro to map sendmsg() to spt_sendmsgx() is available in C applications when
SPT_THREAD_AWARE_NONBLOCK has been defined in the following manner before
including spthread.h:
#define SPT_THREAD_AWARE_NONBLOCK
The alias to link sendmsg() to spt_sendmsgx() is available in C++ applications when
SPT_THREAD_AWARE_PRAGMA_NONBLOCK has been defined in the following manner
before including spthread.h:
#define SPT_THREAD_AWARE_PRAGMA_NONBLOCK
To use this function in a threaded application that uses the Standard POSIX Threads library on
systems running J06.10 or later RVUs or H06.21 or later RVUs, you must perform all of the fol-
lowing tasks:
• Include the spthread.h header file in the application.
• Compile the application using the _SPT_MODEL_ feature test macro or equivalent
compiler command option in addition to any other feature test macros in use.
• Link the application to the zsptdll library (/G/system/zdllnnn/zsptdll).
When data can be sent, a call to the select() function indicates that the file descriptor for the
socket is ready for writing.
RETURN VALUES
Upon successful completion, the spt_sendmsgx() function returns the number of normal bytes
sent. Ancillary data, if present, is not counted in the total number of bytes sent.
If the spt_sendmsgx() function call fails, the value -1 is returned, and errno is set to indicate the
error.
If the socket becomes invalid (is closed by another thread), -1 is returned with an errno value of
[EBADF]. If a signal is received via the pthread_kill() function and is not blocked, ignored, or
handled, -1 is returned with an errno value of [EINTR].
527186-023 Hewlett-Packard Company 7−397