El Mac
El Mac

Reputation: 3419

Java NTP Implementation

I have a server/client application and I need to synchronize the time of the clients with the time of the server. Thereby I need to implement an NTP Server (or similar) on the server application and an NTP client on the client side.

NTP is not a requirement, but it has to be accurate for at least 50ms (then it would be already a bit critical, but still usable, until I figure out a better solution).

Does anyone have any advices, if there is a good implementation that could help me, or if it's doable to implement this by myself (with the desired precision).

Edit: More information about the project

The server application runs on a customers Home PC. The computer of the customer does not have to change the time, only the client (which is running on a dedicated computer, running on Ubuntu).

This is an IoT project, there are many clients that are very small hardwar devices and should have the same date/time as the server. Because the client won't fiddle with the client's configuration, and he does not have access to it (it's a blackbox), I can run my application using admin rights, if needed.

I don't want to install an NTP Server on my client's home PC. This is the reason I want to deliver this functionality inside of my Java Application.

Upvotes: 3

Views: 1195

Answers (1)

Jilles van Gurp
Jilles van Gurp

Reputation: 8294

There's a NtpClient in apache commons-net that you can use for this. You can use this to figure out the clock drift at least of your client pc and try to compensate for that.

Upvotes: 2

Related Questions