Time Shield Library
C++ library for working with time
Loading...
Searching...
No Matches
udp_transport.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2#pragma once
3#ifndef _TIME_SHIELD_UDP_TRANSPORT_HPP_INCLUDED
4#define _TIME_SHIELD_UDP_TRANSPORT_HPP_INCLUDED
5
6#include <cstddef>
7#include <string>
8
9namespace time_shield {
10namespace detail {
11
13 struct UdpRequest {
14 std::string host;
15 int port = 123;
16 const void* send_data = nullptr;
17 std::size_t send_size = 0;
18 void* recv_data = nullptr;
19 std::size_t recv_size = 0;
20 int timeout_ms = 5000;
21 };
22
25 public:
27 virtual ~IUdpTransport() {}
29 virtual bool transact(const UdpRequest& req, int& out_error_code) noexcept = 0;
30 };
31
32} // namespace detail
33} // namespace time_shield
34
35#endif // _TIME_SHIELD_UDP_TRANSPORT_HPP_INCLUDED
Abstract UDP transport interface for NTP queries.
virtual ~IUdpTransport()
Virtual destructor.
virtual bool transact(const UdpRequest &req, int &out_error_code) noexcept=0
Send request and receive response over UDP.
Main namespace for the Time Shield library.
UDP request parameters for NTP transactions.
std::size_t send_size
Outgoing payload size in bytes.
int timeout_ms
Receive timeout in milliseconds.
std::string host
Target host name or IP address.
std::size_t recv_size
Receive buffer size in bytes.
const void * send_data
Pointer to outgoing payload.
void * recv_data
Pointer to receive buffer.