SNTP.time

You're seeing just the function time, go back to SNTP module for more information.

Specs

time(Enumerable.t()) :: {:ok, integer()} | {:error, term()}

Sends a new NTP request on an SNTP.Socket and gracefully closes the socket. Returns {:ok, %SNTP.Timestamp{}} or {:error, reason}

  • options an Enumerable.t() with these keys:
    • host is binary() | charlist() defualts to 'pool.ntp.org'
    • port is an non_neg_integer() between 0..65535 defualts to 123
    • timeout is an non_neg_integer() defualts to :infinity
    • resolve_reference is a boolean() defualts to false

Examples

iex> {:ok, timestamp} = SNTP.time()
iex> timestamp.is_valid?
true

iex> SNTP.time(host: 'ntp.exnet.com', port: 123, timeout: 100))
{:error, [timeout: "Server Timeout after 100"]}