#pragma once

#ifdef _WIN32
#include <WS2tcpip.h>
#include <WinSock2.h>
#endif // _WIN32


class CrNTPUtils
{
public:
	CrNTPUtils();
	~CrNTPUtils();


#ifndef _WIN32
public:
	struct SYSTEMTIME
	{
		int wYear;
		int wMonth;
		int wDayOfWeek;
		int wDay;
		int wHour;
		int wMinute;
		int wSecond;
		int wMilliseconds;
	};
#endif


	/// 初始化NTPClient
	bool InitNTPClient(char* sIP = nullptr,  int nPort = 123);

	/// 退出NTPClient
	bool ExitNTPClient();

	///获取时间
	bool GetSystemTime(SYSTEMTIME& newtime);

private:
	bool _UpdateDate();

private:
	char	m_sIP[16];
	bool	m_bValidIP;
	int		m_nPort;

};

