Xclox
C++11 header-only cross-platform date and time library with an asynchronous NTP client
|
Query is an ephemeral class representing a NTP query from start to end. More...
#include <query.hpp>
Public Types | |
Enumerations & Aliases | |
enum class | Status : uint8_t { ResolveError = 1 , SendError = 2 , ReceiveError = 4 , TimeoutError = 8 , Cancelled = 16 , Succeeded = 32 } |
Type of query status. More... | |
using | Callback = std::function< void(const std::string &, const std::string &, Status, const Packet &, const std::chrono::steady_clock::duration &)> |
Type of query callback. | |
using | DefaultTimeout = internal::DefaultTimeout< QuerySingle, 5000 > |
Type of query timeout milliseconds holder. | |
Public Member Functions | |
Query (const std::string &server, Callback callback) | |
Constructs a NTP query that targets server and uses callback for reporting back its result. | |
void | cancel () |
Cancels the query reporting Query::Status::Cancelled to the caller. | |
Static Public Member Functions | |
static std::weak_ptr< Query > | start (asio::thread_pool &pool, const std::string &server, Callback callback, const std::chrono::milliseconds &timeout=std::chrono::milliseconds(DefaultTimeout::ms)) |
Starts querying all resolved addresses of server one at a time until success. More... | |
Query is an ephemeral class representing a NTP query from start to end.
|
strong |
Type of query status.
|
inlinestatic |
Starts querying all resolved addresses of server
one at a time until success.
pool | a thread pool on which the operations of the query are executed. |
server | a server domain name or address to be resolved for querying. |
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. |