![]() |
jsocketpp 1.0
A cross-platform C++20 socket library.
|
Options controlling a single UDP receive operation. More...
#include <DatagramSocket.hpp>
Public Attributes | |
| DatagramReceiveMode | mode = DatagramReceiveMode::NoPreflight |
| Datagram sizing policy to use during receive. | |
| bool | allowGrow = true |
| Whether the packet buffer may grow before receive (applies to DatagramPacket). | |
| bool | allowShrink = true |
| Whether the packet buffer may shrink after receive (applies to DatagramPacket). | |
| int | recvFlags = 0 |
| Extra flags passed to recv/recvfrom (e.g., MSG_PEEK). | |
| bool | updateLastRemote = true |
| Whether to persist sender into the socket's "last remote" (unconnected sockets). | |
| bool | resolveNumeric = true |
| Whether to resolve numeric host/port into DatagramPacket after receive. | |
| bool | errorOnTruncate {true} |
| When true, the read fails if the incoming datagram would be truncated. | |
Options controlling a single UDP receive operation.
This structure encapsulates the configurable parameters that control how a UDP datagram is received and processed by the DatagramSocket class. It provides fine-grained control over buffer management, system flags, and post-receive behavior.
| bool jsocketpp::DatagramReadOptions::allowGrow = true |
Whether the packet buffer may grow before receive (applies to DatagramPacket).
When true and using PreflightSize mode, allows the implementation to grow the packet buffer if the probed datagram size exceeds current capacity. This can prevent truncation at the cost of potential allocation.
| bool jsocketpp::DatagramReadOptions::allowShrink = true |
Whether the packet buffer may shrink after receive (applies to DatagramPacket).
When true, allows the implementation to shrink the packet buffer to exactly match the received datagram size after a successful receive. This can reduce memory usage but may trigger reallocation on subsequent receives.
| bool jsocketpp::DatagramReadOptions::errorOnTruncate {true} |
When true, the read fails if the incoming datagram would be truncated.
This option determines whether a receive operation should throw when the destination buffer cannot hold the entire datagram:
| DatagramReceiveMode jsocketpp::DatagramReadOptions::mode = DatagramReceiveMode::NoPreflight |
Datagram sizing policy to use during receive.
Controls whether to probe the datagram size before receiving (preflight) or directly read into the provided buffer. See DatagramReceiveMode for details.
| int jsocketpp::DatagramReadOptions::recvFlags = 0 |
Extra flags passed to recv/recvfrom (e.g., MSG_PEEK).
Platform-specific flags that modify the behavior of the underlying receive operation. Common values include:
| bool jsocketpp::DatagramReadOptions::resolveNumeric = true |
Whether to resolve numeric host/port into DatagramPacket after receive.
When true, attempts to convert the sender's address into a human-readable IP string and port number. This may incur additional syscalls but provides convenient access to peer information via DatagramPacket::address and DatagramPacket::port.
| bool jsocketpp::DatagramReadOptions::updateLastRemote = true |
Whether to persist sender into the socket's "last remote" (unconnected sockets).
When true on an unconnected socket, updates the internal state tracking the most recent peer address. This enables getRemoteIp() and getRemotePort() to return information about the last datagram sender.