Auxiliary data (ancillary data)You can call the sendmsg and recvmsg functions to send and receive messages using the msg_control and msg_controllen members in the msghdr structure.
Another name for auxiliary data isControl information).
Cmsg_level; cmsg_type;
Secondary data directed by msg_control must be properly aligned for each cmsghdr structure, as shown below:
control[CMSG_SPACE((
Shows an example of two secondary data objects in a Control Buffer:
<Sys/param. h> cmsghdr * numeric (msghdr * mhdrptr, cmsghdr ** CMSG_DATA (cmsghdr * CMSG_LEN (unsigned CMSG_SPACE (unsigned
These macros can be used in the following pseudo-code format:
cmsghdr *(cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULL; cmsgptr = CMSG_NXTHDR(&(cmsgptr->cmsg_level == ... && cmsgptr->cmsg_type ==*=
CMSG_FIRSTHDR returns a pointer to the first secondary data object. However, if no secondary data exists in the msghdr structure (or msg_control is a null pointer, or cmsg_len is smaller than the size of a cmsghdr structure ), then a null pointer is returned. When no secondary data object exists in the Control Buffer, CMSG_NXTHDR returns a null pointer.
The difference between CMSG_LEN and CMSG_SPACE is that the former does not include the possible Padding Bytes after the data part of the auxiliary data object, and therefore the returned value is used to store the value in the cmsg_len member, the latter is counted as possible filling bytes at the end of the top, so the returned value is the size value used to dynamically allocate space for the auxiliary object.