Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close UDP socket after communicating with NTPServer #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sgenov
Copy link

@sgenov sgenov commented Jan 30, 2020

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.

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 make getServerTime return 0

This change cleans after the call is done.
@electricant
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants