![]() |
NDEVR
API Documentation
|
NTP client that queries a remote NTP server for the current time. More...
Public Member Functions | |
| NtpClient (const StringView &host, uint02 bind_port, uint02 remote_port) | |
| Constructs an NTP client and initiates a time request. | |
| virtual | ~NtpClient () |
| Virtual destructor. | |
| bool | bind (const QHostAddress &bindAddress=QHostAddress::Any, quint16 bindPort=0) |
| void | replyReceived (const QHostAddress &address, quint16 port, const NtpReply &reply) |
| This signal is emitted whenever NTP reply is received. | |
| bool | sendRequest (const QHostAddress &address, quint16 port) |
| Sends an NTP request to the specified address and port. | |
| bool | sendRequest (const String &address, quint16 port) |
| Sends NTP request. | |
| const QUdpSocket * | socket () const |
| Returns the underlying UDP socket used for NTP communication. | |
| Public Member Functions inherited from TimeRequest | |
| void | errorOccurredSignal (int error) |
| Emitted when an error occurs, with the error code. | |
| void | finishedSignal () |
| Emitted when the time request has finished. | |
| TimeSpan | localClockOffset () const |
| Calculates the offset between the local clock and the server clock. | |
| TimeSpan | roundTripDelay () const |
| Calculates the round-trip delay of the time request. | |
Private Member Functions | |
| virtual Time | rxTime () const override |
| Returns the receive time from the NTP reply destination timestamp. | |
| virtual Time | serverTime () const override |
| Returns the server time from the NTP reply origin timestamp. | |
| virtual Time | txTime () const override |
| Returns the transmit time from the NTP reply. | |
NTP client that queries a remote NTP server for the current time.
Inherits from TimeRequest and uses a QUdpSocket to send NTP requests and receive NTP replies. Emits replyReceived when a valid NTP response arrives.
Definition at line 25 of file NtpClient.h.
|
inline |
Constructs an NTP client and initiates a time request.
| [in] | host | The hostname of the NTP server to query. |
| [in] | bind_port | The local UDP port to bind the socket to. |
| [in] | remote_port | The remote NTP server port to send the request to. |
Definition at line 35 of file NtpClient.h.
References StringView::getAs().
|
inline |
| bindAddress | Network address to bind upd socket to. It's passed to QUdpSocket::bind. |
| bindPort | Network port to bind udp socket to. |
Definition at line 72 of file NtpClient.h.
| void NtpClient::replyReceived | ( | const QHostAddress & | address, |
| quint16 | port, | ||
| const NtpReply & | reply ) |
This signal is emitted whenever NTP reply is received.
| address | Address of the server that sent this reply. |
| port | Port of the server that sent this reply. |
| reply | NTP reply. |
References cast(), TimeRequest::finishedSignal(), replyReceived(), and Time::SystemTime().
Referenced by replyReceived().
|
inlineoverrideprivatevirtual |
Returns the receive time from the NTP reply destination timestamp.
Implements TimeRequest.
Definition at line 167 of file NtpClient.h.
|
inline |
Sends an NTP request to the specified address and port.
| [in] | address | NTP server address. |
| [in] | port | NTP server port. |
Definition at line 104 of file NtpClient.h.
References ClientMode, NtpPacket::flags, NtpPacketFlags::mode, Time::SystemTime(), NtpPacket::transmitTimestamp, and NtpPacketFlags::versionNumber.
|
inline |
Sends NTP request.
| address | NTP server address. |
| port | NTP server port. |
Definition at line 93 of file NtpClient.h.
References String::getAs(), and sendRequest().
Referenced by sendRequest().
|
inlineoverrideprivatevirtual |
Returns the server time from the NTP reply origin timestamp.
Implements TimeRequest.
Definition at line 159 of file NtpClient.h.
|
inline |
Returns the underlying UDP socket used for NTP communication.
Definition at line 121 of file NtpClient.h.
|
inlineoverrideprivatevirtual |
Returns the transmit time from the NTP reply.
Implements TimeRequest.
Definition at line 175 of file NtpClient.h.