局域网内,用C#实现本地电脑获取服务器系统时间,并更新到本地电脑
2021-01-19 22:14
标签:receive client cond 主机 connect nec system 服务器 min //从本机获取服务器时间 局域网内,用C#实现本地电脑获取服务器系统时间,并更新到本地电脑 标签:receive client cond 主机 connect nec system 服务器 min 原文地址:https://www.cnblogs.com/yxd000/p/12151722.html
SNTPTimeClient client = new SNTPTimeClient("10.0.5.126", "123");///////填写你想要的获取时间的主机的IP和端口;
client.Connect();
DateTime getEd = client.ReceiveTimestamp;//获取指定IP的系统时间
SystemTime st = new SystemTime
{
wDay = (ushort)getEd.Day,
wDayOfWeek = (ushort)getEd.DayOfWeek,
wHour = (ushort)getEd.Hour,
wMiliseconds = (ushort)getEd.Millisecond,
wMinute = (ushort)getEd.Minute,
wMonth = (ushort)getEd.Month,
wSecond = (ushort)getEd.Second,
wYear = (ushort)getEd.Year
};
SNTPTimeClient.SetLocalTime(st);//设置本地时间;
文章标题:局域网内,用C#实现本地电脑获取服务器系统时间,并更新到本地电脑
文章链接:http://soscw.com/index.php/essay/44256.html