Skip to content

Example NTP‐Client

ANYKS edited this page Nov 25, 2024 · 2 revisions
#include <net/ntp.hpp>
#include <core/core.hpp>

using namespace std;
using namespace awh;

int32_t main(int32_t argc, char * argv[]){
	fmk_t fmk;
	log_t log(&fmk);
	ntp_t ntp(&fmk, &log);
	core_t core(&fmk, &log);

	log.name("NTP");
	log.format("%H:%M:%S %d.%m.%Y");

	ntp.ns({"77.88.8.88", "77.88.8.2"});

	ntp.servers({"0.ru.pool.ntp.org", "1.ru.pool.ntp.org", "2.ru.pool.ntp.org", "3.ru.pool.ntp.org"});

	log.print("Time: %s", log_t::flag_t::INFO, fmk.time2str((ntp.request() / 1000), "%H:%M:%S %d.%m.%Y").c_str());

	return EXIT_SUCCESS;
}