Open System Services System Calls Reference Manual (G06.28+, H06.05+)
System Functions (s and S) spt_sendmsgx(2)
Successful completion of a call to spt_sendmsgx( ) does not imply successful delivery of the
message. A return value of -1 indicates only locally detected errors.
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
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].
ERRORS
If any of these conditions occur, the spt_sendmsgx() function sets errno to the corresponding
value:
[EACCES] The socket is in the AF_UNIX domain and either search permis-
sion is denied for a component of the pathname in the msghdr
527186-007 Hewlett-Packard Company 7−297