Socket module

CMSG_FIRSTHDR

procedure · 1 overloadSource

Returns the first control message of message, or null when its control buffer is smaller than one header.

message must be a live msghdr whose msg_control and msg_controllen describe the buffer. The result points into that buffer and is not a separate allocation. Control messages carry ancillary data such as descriptors (SCM_RIGHTS) with sendmsg and recvmsg, and exist on Unix only.

Example
message: msghdr;
assert(CMSG_FIRSTHDR(*message) == null);

buffer: [64] u8;
message.msg_control = buffer.data;
message.msg_controllen = xx buffer.count;
assert(cast(*u8) CMSG_FIRSTHDR(*message) == buffer.data);

Doesn't run in the browser (only on linux, macos).

CMSG_FIRSTHDR :: (mhdr: *msghdr) -> *cmsghdr

Returns the first control message of message, or null when its control buffer is smaller than one header.

message must be a live msghdr whose msg_control and msg_controllen describe the buffer. The result points into that buffer and is not a separate allocation. Control messages carry ancillary data such as descriptors (SCM_RIGHTS) with sendmsg and recvmsg, and exist on Unix only.

Parameters

mhdr: *msghdr

Returns

*cmsghdr
Example
message: msghdr;
assert(CMSG_FIRSTHDR(*message) == null);

buffer: [64] u8;
message.msg_control = buffer.data;
message.msg_controllen = xx buffer.count;
assert(cast(*u8) CMSG_FIRSTHDR(*message) == buffer.data);

Doesn't run in the browser (only on linux, macos).

See also