msghdr

Contains message information.

Service:Networking

Syntax

  #include <sys/socket.h>
  
  struct msghdr 
  {
     caddr_t       *msg_name; 
     socklen_t      msg_namelen; 
     struct iovec  *msg_iov; 
     int            msg_iovlen; 
     caddr_t       *msg_accrights; 
     socklen_t      msg_accrightslen;
  #define msg_control     msg_accrights
  #define msg_controllen  msg_accrightslen
     int            msg_flags;
  };
  

Fields

msg_name

Points to an optional address.

msg_namelen

Specifies the size of msg_name.

msg_iov

Points to the scatter/gather array.

msg_iovlen

Specifies the number of elements in msg_iov.

msg_accrights or msg_control

The double define for this field allows this structure to be used in a BSD 4.3 or Linux environment. As msg_accrights, is unused (set to 0). As msg_control, points to a buffer containing ancillary data.

msg_accrightslen or msg_controllen

The double define for this field allows this structure to be used in a BSD 4.3 or Linux environment. As msg_accrightslen, is unused (set to 0). As msg_controllen, specifies the length of the ancillary data that follows this structure. The ancillary data consists of a cmsghdr structure followed by the acutual data. See cmsghdr.

msg_flags

Reserved.

Remarks

The msg_name and msg_addrlen fields specify the source address if the socket is unconnected. If the address isn't desired, it can be set to NULL. If the socket is connected, the msg_name and msg_addrlen fields are ignored. The msg_iov and msg_iovlen fields specify where the data is stored.