-
Notifications
You must be signed in to change notification settings - Fork 0
Network
Tom Colas edited this page Jan 18, 2026
·
1 revision
network.hpp contains the low-level networking primitives shared by both client and server.
It defines packet structures, headers, SAFE packet tracking, and the packet_handler.
| Field | Type | Description |
|---|---|---|
id |
size_t | Message / entity identifier |
protocol |
uint16_t | BASIC or SAFE |
safeUid |
uint16_t | SAFE acknowledgment ID |
size |
uint16_t | Payload size |
type |
uint16_t | Message type |
struct Packet {
Header header;
const void *data;
};Tracks unacknowledged SAFE packets.
std::unordered_map<
int, std::unordered_map<int, SafePacket>
>- Timeout:
TIME_OUT(default: 100ms) - Retransmission continues until ACK is received
- Automatic cancellation on client disconnect
Responsible for:
- Packet serialization
- Sending packets
- SAFE retransmission scheduling
- ACK handling
| Name | Value |
|---|---|
TIME_OUT |
100 ms |
DEFAULT_SAFE_UID |
0 |
| Max Packet Size | 1024 bytes |
- UDP-first architecture
- Explicit reliability when needed
- Minimal overhead for real-time gameplay