The latest development version of this page may be more current than this released 1.14.0 version.

Simple Network Time Protocol Library

Overview

The SNTP library implements IETF RFC4330 (Simple Network Time Protocol v4).

SNTP provides a way to synchronize clocks in computer networks.

API Reference

group sntp

Simple Network Time Protocol API.

Functions

int sntp_init(struct sntp_ctx *ctx, struct sockaddr *addr, socklen_t addr_len)

Initialize SNTP context.

Return
0 if ok, <0 if error.
Parameters
  • ctx: Address of sntp context.
  • addr: IP address of NTP/SNTP server.
  • addr_len: IP address length of NTP/SNTP server.

int sntp_request(struct sntp_ctx *ctx, u32_t timeout, u64_t *epoch_time)

Send SNTP request.

Return
0 if ok, <0 if error.
Parameters
  • ctx: Address of sntp context.
  • timeout: Timeout of waiting for sntp response (in milliseconds).
  • epoch_time: Seconds since 1 January 1970.

void sntp_close(struct sntp_ctx *ctx)

Release SNTP context.

Parameters
  • ctx: Address of sntp context.

struct sntp_ctx
#include <sntp.h>

SNTP context