Xclox
C++11 header-only cross-platform date and time library with an asynchronous NTP client
|
QuerySingle is an ephemeral class representing a single NTP query. More...
#include <query_single.hpp>
Public Types | |
Aliases | |
using | Callback = std::function< void(const asio::ip::udp::endpoint &, const asio::error_code &, const Packet &, const std::chrono::steady_clock::duration &)> |
Type of query callback. | |
using | DefaultTimeout = internal::DefaultTimeout< QuerySingle, 3000 > |
Type of query timeout milliseconds holder. | |
Public Member Functions | |
QuerySingle (asio::io_context &io, const std::chrono::milliseconds &timeout) | |
Constructs a single NTP query on the given context that runs within the given timeout duration. | |
void | cancel () |
Cancels the query reporting asio::error::operation_aborted to the caller. | |
Static Public Member Functions | |
static std::weak_ptr< QuerySingle > | start (asio::io_context &io, const asio::ip::udp::endpoint &server, Callback callback, const std::chrono::milliseconds &timeout=std::chrono::milliseconds(DefaultTimeout::ms)) |
Starts querying the given endpoint. More... | |
QuerySingle is an ephemeral class representing a single NTP query.
|
inlinestatic |
Starts querying the given endpoint.
io | a run context on which the operations of the query are executed. |
server | a server address to be queried. |
callback | a callable to report the result of the query to the caller. |
timeout | a time duration after which the query is cancelled if it is not completed. |