86 std::span<const uint8_t> data,
87 const std::string& from_address,
114 bool start_client(std::string_view remote_host, uint16_t remote_port, uint16_t local_port = 0);
142 bool send_to(std::span<const uint8_t> data, std::string_view host, uint16_t port);
225 std::span<const uint8_t> data,
226 const std::string& from_address,
227 uint16_t from_port)>;
251 bool start_server(uint16_t port);
259 bool start_server(std::string_view address, uint16_t port);
273 bool send_to(std::span<const uint8_t> data, std::string_view host, uint16_t port);
282 bool send_to(std::string_view data, std::string_view host, uint16_t port);
290 bool broadcast(std::span<const uint8_t> data, uint16_t port);
302 std::string_view server_id() const noexcept;
393 bool send_reliable(std::span<const uint8_t> data);
400 bool send_unreliable(std::span<const uint8_t> data);
406 bool is_connected() const noexcept;
448 void set_retransmit_timeout(std::chrono::milliseconds timeout);
454 void set_max_retransmit_attempts(
size_t max_attempts);
460 std::chrono::milliseconds get_rtt() const noexcept;
466 double get_packet_loss_rate() const noexcept;
A UDP client that sends datagrams to a target endpoint and can receive responses.
auto client_id() const -> const std::string &
Returns the client identifier.
void set_data_callback(udp_data_callback callback)
Set data received callback.
bool send_packet(std::span< const uint8_t > data)
Send a datagram to the configured remote endpoint.
bool leave_multicast_group(std::string_view multicast_address)
Leave multicast group.
std::unique_ptr< impl > pimpl_
auto stop_client() -> VoidResult
Stops the client and releases all resources.
bool send_to(std::span< const uint8_t > data, std::string_view host, uint16_t port)
Send a datagram to a specific endpoint.
bool join_multicast_group(std::string_view multicast_address)
Enable multicast reception.
messaging_udp_client(std::string_view client_id)
Construct a UDP client with a given client_id.
std::function< void( std::span< const uint8_t > data, const std::string &from_address, uint16_t from_port)> udp_data_callback
Callback type for UDP data reception.
virtual ~messaging_udp_client() noexcept
Destructor - automatically stops the client if running.
auto is_running() const -> bool override
Checks if the client is currently running.
auto start_client(std::string_view host, uint16_t port) -> VoidResult
Starts the client by resolving target host and port.
auto set_error_callback(error_callback_t callback) -> void override
Sets the callback for errors.
A UDP server that receives datagrams and routes them based on sender endpoint.
std::function< void( std::span< const uint8_t > data, const std::string &from_address, uint16_t from_port)> udp_data_callback
Callback type for UDP data reception.
messaging_udp_server(std::string_view server_id)
Construct a UDP server with a given server_id.
virtual ~messaging_udp_server() noexcept
Destructor - automatically stops the server if running.
A UDP client with optional reliability layer for configurable delivery guarantees.
virtual ~reliable_udp_client() noexcept
Destructor.
reliable_udp_client(std::string_view client_id)
Construct a reliable UDP client.
std::function< void()> disconnection_callback
std::function< void()> connection_callback
Callback type aliases for messaging.
std::function< void(const std::string &)> error_callback
std::function< void(std::span< const uint8_t >)> data_callback