Hey all,
Having an issue with an NTP time server class. I am not a networking expert so perhaps someone with networking experience may be able to take a guess at the issue. I am not confident that the problem is not the Netduino Plus 2 although everything on the Netduino seems fine.
So, first I am loading the Network settings from the SD card. I have ensured and double checked that I have a valid IP address and it is not in conflict. I also have a proper subnet Mask, Gateway and the Primary and Secondary DNS servers are in deed correctly pulled and match those from my Cable model. So it seems that DHCP on the Netduino is working correctly.
I am getting two failure points. First it fails on the DNS lookup of the time server. The time server I am using in this case is pool.ntp.org (I've also tried others). The codeline is as follows:
IPAddress[] address = Dns.GetHostEntry("pool.ntp.org").AddressList;
When it runs it sits on this line for x seconds then throws an exception of "Exception was thrown: System.Net.Sockets.SocketException".
I have a try/catch around it setting a backup IP address for the address if GetHostEntry fails. Then, since either way we'll have an IP Address. I create the Socket and all looks good however it seems to time out. The code I am using uses socket.Poll after using the socket.SendTo to send the request Code follows:
if (s.Poll(30 * 1000 * 1000, SelectMode.SelectRead))
The 30 * 1000 * 1000 is the number of microseconds to wait (timeout) so this is 30 seconds. They recommend 10 but I have it a little longer. It basically sits for the 30 seconds then s.Poll returns "false" thus skipping all the time extraction code and finally closing the socket.
I have checked everything I can think of and I am unsure why it fails on the DNS lookup as well as times out on the polling.
Does anyone have NTP successfully working on the Netduino Plus 2? Has anyone experienced such an issue and found a solution for it?