I am trying to query an NTP Server using c# to get the time of NTP server using the following source code from this thread How to Query an NTP Server using C#? .For some reason the flow stops at socket.Receive(ntpData).

1) Any idea why it is stopping?

2)How to get the time from a ntp server using windows command line so that if it works than my program should work .

有帮助吗?

解决方案

1) The most likely reason your program is stopping is because of no network response this can be caused by the network blocking for Udp, port 123 etc.

2) You can use the ntpq program to query from command line (NTP)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top