EasyNTPClient icon indicating copy to clipboard operation
EasyNTPClient copied to clipboard

Close UDP socket after communicating with NTPServer

Open sgenov opened this issue 5 years ago • 1 comments

We should close the socket after using it. There is no reason to keep it open. If we want to destroy the first EasyNTPClient instance and then create another one later on, the socket will be taken. This will result in a failure to "ntp->begin(123)", which makes getServerTime return 0

This change cleans after the call is done.

sgenov avatar Jan 30 '20 09:01 sgenov

For this patch to work you have to remove the keyword 'static' from line 43 on EasyNTPClient.cpp. Otherwise, the NTP request will succeed only once.

electricant avatar Apr 07 '21 13:04 electricant