-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy path_test_ntp_client.cpp
More file actions
36 lines (33 loc) · 961 Bytes
/
_test_ntp_client.cpp
File metadata and controls
36 lines (33 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* @file NTP client
* @brief
* @ref
* @author Yonhgwhan, Roh (fixbrain@gmail.com)
* @date 05.08.2024 created.
* @copyright All rights reserved by Yonghwan, Roh.
**/
#include "stdafx.h"
#include "_MyLib/src/ntp_client.h"
bool ntp_client()
{
_mem_check_begin
{
try
{
boost::asio::io_context io_context;
NTPClient client(io_context, "pool.ntp.org", 1);
client.get_ntp_time();
io_context.run();
std::cout
<< "Local : " << time_now_to_str(true, true) << std::endl
<< "NTP : " << file_time_to_str(client.get_ntp_as_filetime(), true, true) << " " << std::endl
<< "delta : " << client.get_delta_sec() << (" sec") << std::endl;
}
catch (const std::exception& e)
{
std::cerr << "Exception: " << e.what() << std::endl;
}
}
_mem_check_end;
return true;
}