zephyr/samples/net/sockets/sntp_client
Jukka Rissanen 5c3fa85bc8 samples: net: Change to use CONFIG_POSIX_API
Change the sample applications that use network socket API to
use the POSIX_API config because the NET_SOCKETS_POSIX_NAMES is
deprecated. Convert also the zsock_ API calls to plain BSD
socket API calls when applicable.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-03-27 13:40:13 -05:00
..
boards
src samples: net: Change to use CONFIG_POSIX_API 2024-03-27 13:40:13 -05:00
CMakeLists.txt
prj.conf samples: net: Change to use CONFIG_POSIX_API 2024-03-27 13:40:13 -05:00
README.rst samples sntp_client: Move from native_posix to native_sim 2023-11-15 10:03:17 +01:00
sample.yaml samples: net: Change to use CONFIG_POSIX_API 2024-03-27 13:40:13 -05:00

.. zephyr:code-sample:: sntp-client
   :name: SNTP client
   :relevant-api: bsd_sockets sntp

   Use SNTP to get the current time from the host.

Overview
********

This sample is a simple SNTP client showing how to retrieve the current
time in seconds since 1st January 1970.

This demo assumes that the platform of choice has networking support,
some adjustments to the configuration may be needed. It also assumes
SNTP server is running on the host.

Building and Running
********************

When the application runs, it issues an SNTP request to the host and waits
for a response. When the response is received, the current epoch time, in
seconds, as well as the status code of the response (0 on success), is
printed.

See the `net-tools`_ project for more details.

This sample can be built and executed on QEMU or native_sim board as
described in :ref:`networking_with_qemu`.

.. _`net-tools`: https://github.com/zephyrproject-rtos/net-tools