• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

src/03-Apr-2024-256185

CMakeLists.txtD03-Apr-2024295 127

README.rstD03-Apr-20241.7 KiB5237

overlay-e1000.confD03-Apr-2024122 73

prj.confD03-Apr-2024969 3927

sample.yamlD03-Apr-2024407 1715

README.rst

1.. zephyr:code-sample:: sockets-service-echo
2   :name: Echo server (service)
3   :relevant-api: bsd_sockets
4
5   Implements a simple IPv4/IPv6 TCP echo server using BSD sockets and socket service API.
6
7Overview
8********
9
10The sockets/echo_service sample application for Zephyr implements a TCP echo
11server supporting both IPv4 and IPv6 and using a BSD Sockets compatible API.
12
13The purpose of this sample is to show how to use socket service API.
14The socket service is a concept where many blocking sockets can be listened by
15one thread, and which can then trigger a callback if there is activity in the set
16of sockets. This saves memory as only one thread needs to be created in the
17system.
18
19The application supports IPv4 and IPv6, and both UDP and TCP are also supported.
20The source code for this sample application can be found at:
21:zephyr_file:`samples/net/sockets/echo_service`.
22
23Requirements
24************
25
26- :ref:`networking_with_host`
27- or, a board with hardware networking
28
29Building and Running
30********************
31
32Build the Zephyr version of the sockets/echo_service application like this:
33
34.. zephyr-app-commands::
35   :zephyr-app: samples/net/sockets/echo_service
36   :board: <board_to_use>
37   :goals: build
38   :compact:
39
40After the sample starts, it expects connections at 192.0.2.1, or 2001:db8::1
41and port 4242.
42The easiest way to connect is:
43
44.. code-block:: console
45
46    $ telnet 192.0.2.1 4242
47
48After a connection is made, the application will echo back any line sent
49to it. The application implements a single-threaded server using blocking
50sockets, and currently is only implemented to serve only one client connection
51at time. After the current client disconnects, the next connection can proceed.
52