|
libcosmos
Linux C++ System Programming Library
|
Wrapper for struct msghdr for sending messages via Socket::sendMessage().
More...
#include <message_header.hxx>
Inheritance diagram for cosmos::SendMessageHeader:Classes | |
| class | ControlMessage |
Wrapper for struct cmsghdr used for creating new control messages for sending. More... | |
Public Attributes | |
| WriteIOVector | iovec |
| Memory regions to send. | |
| std::optional< ControlMessage > | control_msg |
| Control message to send, if any. | |
Protected Member Functions | |
| void | prepareSend (const SocketAddress *addr) |
Prepare a sendmsg() operation using the given optional target address. | |
| void | postSend (size_t sent) |
Perform any cleanup or bookkeeping after a successful sendmsg() operation. | |
| void | setAddress (const SocketAddress &addr) |
Fill in the target address fields of the struct msghdr for the given address object. | |
| const struct msghdr * | rawHeader () const |
Return a pointer to the raw struct msghdr for passing to the sendmsg() system call. | |
Protected Member Functions inherited from cosmos::MessageHeaderBase< msghdr_const > | |
| void | resetAddress () |
| Reset the address portion of the msghdr struct. | |
| void | setIov (IOVEC &iovec) |
Set the msg_iov fields of the msghdr struct based on the given iovector object. | |
| MessageFlags | ioFlags () const |
| Returns the currently set MessageFlags for send/receive. | |
Friends | |
| class | Socket |
Additional Inherited Members | |
Public Member Functions inherited from cosmos::MessageHeaderBase< msghdr_const > | |
| MessageHeaderBase () | |
| Create a MSGHDR initialized to all zeroes and with default flags applied. | |
| void | clear () |
| Clear the complete system call structure with zeroes. | |
| void | setIOFlags (const MessageFlags flags) |
| Set the flags used for sending or receiving data. | |
Protected Attributes inherited from cosmos::MessageHeaderBase< msghdr_const > | |
| msghdr_const | m_header |
The low level struct msghdr | |
| MessageFlags | m_io_flags |
| The currently configured send/receive flags. | |
Wrapper for struct msghdr for sending messages via Socket::sendMessage().
This type holds extended data for sending a message over a socket. For one it allows sending data from multiple scattered memory regions using a WriteIOVector. Furthermore additional ancillary data can be sent. Both of these items can be set using the public members iovec and control_msg. These variables will be applied when passing the SendMessageHeader to Socket::sendMessage() or one of its specializations.
Libcosmos currently only supports sending a single control message at once. The ControlMessage type can only be constructed by special types that know how to serialize one like the UnixRightsMessage type for sending file descriptors over a UNIX domain socket.
There are some restrictions when sending ancillary data. With SocketType::STREAM sockets ancillary data must always be accompanied by some payload data. If no payload data is otherwise available then a dummy byte needs to be sent to make it possible to send ancillary data. On SocketType::DGRAM sockets on Linux it is also possible to send ancillary data without any payload.
Definition at line 141 of file message_header.hxx.
|
inlineprotected |
Perform any cleanup or bookkeeping after a successful sendmsg() operation.
Definition at line 222 of file message_header.hxx.
|
protected |
Prepare a sendmsg() operation using the given optional target address.
Definition at line 25 of file message_header.cxx.
|
inlineprotected |
Return a pointer to the raw struct msghdr for passing to the sendmsg() system call.
Definition at line 231 of file message_header.hxx.
|
protected |
Fill in the target address fields of the struct msghdr for the given address object.
Definition at line 12 of file message_header.cxx.
|
friend |
Definition at line 143 of file message_header.hxx.
| std::optional<ControlMessage> cosmos::SendMessageHeader::control_msg |
Control message to send, if any.
Definition at line 214 of file message_header.hxx.
| WriteIOVector cosmos::SendMessageHeader::iovec |
Memory regions to send.
Definition at line 212 of file message_header.hxx.