public void sync(string host_name) { try { var connection = new NtpConnection(host_name); stop_watch = new Stopwatch(); stop_watch.Stop(); var utcNow = connection.GetUtc(); stop_watch.Start(); time_offset = (long)(utcNow - new DateTime(1970, 1, 1)).TotalMilliseconds; reportLog("NTP Sync successful", LogType.INFO, "NTPClient"); reportLog("Current time is : " + get(), LogType.INFO, "NTPClient"); } catch (Exception e) { string msg = e.Message; reportLog("Error in time sync : " + msg, LogType.ERROR, "NTPClient"); } }
public Net2NTP(string ntpServer) { var connection = new NtpConnection(ntpServer); }