Function sntpc::sntp_process_response
source · pub fn sntp_process_response<A, U, T>(
dest: A,
socket: &U,
context: NtpContext<T>,
send_req_result: SendRequestResult
) -> Result<NtpResult>
Expand description
Process SNTP response from a server
That function along with the sntp_send_request
is required under an environment(s)
where you need to call TCP/IP stack helpers (like poll
, wait
, etc.)
Args:
dest
- NTP server’s address to send request tosocket
- Socket reference to use for sending a NTP requestcontext
- SNTP client contextsend_req_result
- send request result that obtained aftersntp_send_request
call
Example
use sntpc::{self, NtpContext, NtpTimestampGenerator, Result};
// implement required trait on network objects
// implement required trait on the timestamp generator object
// "time.google.com:123" string here used for the sake of simplicity. In the real app
// you would want to fix destination address, since string hostname may resolve to
// different IP addresses
if let Ok(result) = sntpc::sntp_send_request("time.google.com:123", &socket, ntp_context) {
let time = sntpc::sntp_process_response("time.google.com:123", &socket, ntp_context, result);
}