waterlinkedsonar
C++ client library for the Water Linked Sonar 3D-15
Loading...
Searching...
No Matches
Functions
sntp.hpp File Reference

Single SNTP query for checking an NTP server. More...

#include <chrono>
#include <cstdint>
#include <optional>
#include <string>

Go to the source code of this file.

Functions

std::optional< std::chrono::system_clock::time_point > waterlinked::sonar::sntp_query (const std::string &server, std::chrono::milliseconds timeout, std::uint16_t port=123)
 Asks an NTP server for its time with one SNTP (RFC 4330) request, e.g.
 

Detailed Description

Single SNTP query for checking an NTP server.

Function Documentation

◆ sntp_query()

std::optional< std::chrono::system_clock::time_point > waterlinked::sonar::sntp_query ( const std::string &  server,
std::chrono::milliseconds  timeout,
std::uint16_t  port = 123 
)

Asks an NTP server for its time with one SNTP (RFC 4330) request, e.g.

to check a server before configuring it on the sonar.

Parameters
serverHostname or IPv4 address.
timeoutLimit for the response.
portUDP port of the server.
Returns
The server's transmit time, or std::nullopt if the server does not resolve, no valid server reply arrives within timeout, or the server is not synchronized (leap indicator 3, stratum outside 1-15, or zero transmit time).