ark::time::NtpClient

Defined in header “ark/time/ntp_client.hh”.


This represents a client that can synchronize to a remote NTP source. You initialize it against the server that you wish to communicate through, and then run poll() periodically to handle results.

The client will periodically emit time pairs, which you can then use in whatever time synchronization algorithm you like.

Methods

  • NtpClient(comms::NetworkAddress server_address)
    Constructor. Initializes against the given server address.

  • const comms::NetworkAddress & address()
    Returns the address that this network client is talking to.

  • void poll(std::chrono::nanoseconds duration)
    This polls the socket it checks to see if we need to send a remote request for time, and also waits for responses. Call this from a message pump to update state.

  • size_t queued_time_pair_count()
    Returns a count of the time pairs that are queued but not popped.

  • std::vector< NtpTimePair > pop_time_pairs()
    Pops all of the queued time pairs, returning them to the caller.