Wraps a NET_DatagramSocket with header-prefixed I/O.
More...
#include <UdpEndpoint.hpp>
|
| NET_DatagramSocket * | socket_ = nullptr |
Wraps a NET_DatagramSocket with header-prefixed I/O.
Same class is used in both server mode (binds to a port) and client mode (binds to any free port). Distinction is which open overload you call.
◆ UdpEndpoint() [1/3]
| net::UdpEndpoint::UdpEndpoint |
( |
| ) |
|
|
default |
◆ UdpEndpoint() [2/3]
| net::UdpEndpoint::UdpEndpoint |
( |
const UdpEndpoint & | | ) |
|
|
delete |
◆ UdpEndpoint() [3/3]
| net::UdpEndpoint::UdpEndpoint |
( |
UdpEndpoint && | | ) |
|
|
delete |
◆ ~UdpEndpoint()
| net::UdpEndpoint::~UdpEndpoint |
( |
| ) |
|
|
inline |
◆ close()
| void net::UdpEndpoint::close |
( |
| ) |
|
|
noexcept |
Close the socket. Idempotent.
◆ isOpen()
| bool net::UdpEndpoint::isOpen |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
True after a successful open.
◆ open()
| bool net::UdpEndpoint::open |
( |
const char * | bindAddr, |
|
|
Uint16 | port ) |
Bind a UDP socket to bindAddr:port (server) or to any free port (client, with bindAddr = nullptr and port = 0).
- Returns
- False on bind / DNS / socket-creation failure.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ send()
Send a payload with our header prefixed, to dest.
Constructs the on-the-wire datagram = [PacketHeader][payload]. Caller fills the relevant header fields (channel / sequence / connectionId) — magic, version, kind=Payload, _pad are filled here.
- Returns
- False on socket error or oversize payload.
◆ sendFragmented()
Send a payload by splitting it into MTU-safe fragments.
Stage 3d-4: snapshots at 100 players are ~5 KB, well over the MTU-safe k_maxPayloadBytes (~1184 bytes per single datagram). This helper splits data into ceil(len / k_maxPayloadBytes) fragments. Each fragment carries the same (channel, sequence) in its PacketHeader plus the bit-0-set flags.fragmented, with fragmentInfo packing (index << 8) | count.
The receiver pairs them by (connectionId, sequence) in a FragmentReassembler. Drop-stale: a newer sequence supersedes any in-progress reassembly. Single dropped fragment loses the whole snapshot — fine because the next snapshot lands ~31 ms later.
- Parameters
-
| dest | Destination address. |
| hdr | Caller-supplied header. flags and fragmentInfo are overwritten per-fragment. |
| data | Payload bytes (split internally). |
| dataLen | Total payload length. |
- Returns
- False on socket error or if the payload would need more than 256 fragments (sanity cap; 256 × ~1.18 KB ≈ 302 KB logical-message ceiling, vastly more than we'll need).
◆ tryReceive()
Try to receive one datagram (non-blocking).
- Parameters
-
- Returns
- True if a datagram was received and parsed; false if the queue was empty or the datagram was malformed (in which case it's silently dropped — UDP is best-effort).
◆ socket_
| NET_DatagramSocket* net::UdpEndpoint::socket_ = nullptr |
|
private |
The documentation for this class was generated from the following files: