![]() |
jsocketpp 1.0
A cross-platform C++20 socket library.
|
Policy for enforcing an exact-byte receive on a single UDP datagram. More...
#include <DatagramSocket.hpp>

Public Attributes | |
| DatagramReadOptions | base {} |
| Base receive options for controlling preflight behavior, system flags, and side effects. | |
| bool | requireExact = true |
| Controls whether the datagram size must match exactly. | |
| bool | padIfSmaller = false |
| Controls zero-padding behavior for undersized datagrams. | |
| bool | errorOnTruncate = true |
| Controls error handling for oversized datagrams. | |
| bool | autoResizeDynamic = true |
| Controls automatic resizing of dynamic containers. | |
Policy for enforcing an exact-byte receive on a single UDP datagram.
This structure defines the policy for reading a UDP datagram that must match a specific size requirement. It provides fine-grained control over the handling of datagrams that are larger or smaller than the expected size, including padding behavior and error handling.
| bool jsocketpp::ReadExactOptions::autoResizeDynamic = true |
Controls automatic resizing of dynamic containers.
When true and receiving into a dynamic container (e.g., std::string, std::vector), the container will be automatically resized to the exact size before the receive operation.
This ensures efficient memory use but may trigger reallocation.
| DatagramReadOptions jsocketpp::ReadExactOptions::base {} |
Base receive options for controlling preflight behavior, system flags, and side effects.
This field inherits the core receive options from DatagramReadOptions, including:
| bool jsocketpp::ReadExactOptions::errorOnTruncate = true |
Controls error handling for oversized datagrams.
When true, receiving a datagram larger than the requested size will throw a SocketException. When false, the datagram is silently truncated to the requested size.
| bool jsocketpp::ReadExactOptions::padIfSmaller = false |
Controls zero-padding behavior for undersized datagrams.
When true and the received datagram is smaller than the requested size:
| bool jsocketpp::ReadExactOptions::requireExact = true |
Controls whether the datagram size must match exactly.
When true, the datagram's payload size must match the requested size exactly; otherwise, a SocketException is thrown. This enforces strict size matching for protocols that require fixed-size messages.