Understanding struct msghdr

This appears to be a formidable structure to establish when seeing it for the first time. But don't fear the penguins! Examine the following structure definition:

call.

EXAMPLE

EXAMPLE

struct msghdr {

void socklen_t struct iovec size_t void size_t int

*msg_name;

msg_namelen;

msg_iovlen;

*msg_control;

msg_controllen;

msg_flags;

NOTE:

Prior to the Posix.lg standard, the msg_name and msg_control members were typically defined as C data type (char *). Additionally, members msg_namelen and msg_controllen were previously declared as int types.

The structure members can be divided into four groups. These are

• Socket address members msg_name and msg_namelen.

• I/O vector references msg_iov and msg_iovlen.

• Ancillary data buffer members msg_control and msg_controllen.

• Received message flag bits msg_flags.

After you divide this structure into the preceding categories, the structure becomes less intimidating.

Was this article helpful?

0 0

Post a comment