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

..--

boards/11-Mar-2024-4931

src/11-Mar-2024-10275

CMakeLists.txtD11-Mar-2024287 127

Makefile.posixD11-Mar-2024119 52

README.rstD11-Mar-20242.1 KiB8454

overlay-e1000.confD11-Mar-2024141 84

overlay-log.confD11-Mar-2024298 158

prj.confD11-Mar-2024443 2113

sample.yamlD11-Mar-2024340 1413

README.rst

1.. _sockets-echo-sample:
2
3Socket Echo Server
4##################
5
6Overview
7********
8
9The sockets/echo sample application for Zephyr implements an IPv4 TCP echo
10server using a BSD Sockets compatible API. The purpose of this sample is to
11show how it's possible to develop a sockets application portable to both
12POSIX and Zephyr. As such, it is kept minimal and supports only IPv4 and TCP.
13
14The source code for this sample application can be found at:
15:zephyr_file:`samples/net/sockets/echo`.
16
17Requirements
18************
19
20- :ref:`networking_with_host`
21- or, a board with hardware networking
22
23Building and Running
24********************
25
26Build the Zephyr version of the sockets/echo application like this:
27
28.. zephyr-app-commands::
29   :zephyr-app: samples/net/sockets/echo
30   :board: <board_to_use>
31   :goals: build
32   :compact:
33
34After the sample starts, it expects connections at 192.0.2.1, port 4242.
35The easiest way to connect is:
36
37.. code-block:: console
38
39    $ telnet 192.0.2.1 4242
40
41After a connection is made, the application will echo back any line sent
42to it. The application implements a single-threaded server using blocking
43sockets, and thus can serve only one client connection at time. After the
44current client disconnects, the next connection can proceed.
45
46Running application on POSIX Host
47=================================
48
49The same application source code can be built for a POSIX system, e.g.
50Linux. (Note: if you look at the source, you will see that the code is
51the same except the header files are different for Zephyr vs POSIX.)
52
53To build for a host POSIX OS:
54
55.. code-block:: console
56
57    $ make -f Makefile.posix
58
59To run:
60
61.. code-block:: console
62
63    $ ./socket_echo
64
65To test:
66
67.. code-block:: console
68
69    $ telnet 127.0.0.1 4242
70
71As can be seen, the behavior of the application is the same as the Zephyr
72version.
73
74Running on cc3220sf_launchxl
75============================
76
77See the note on Provisioning and Fast Connect in :ref:`cc3220sf_launchxl`.
78
79After having connected to an Access Point using the sample Wi-Fi shell,
80the IP address will be printed to the console upon running this echo
81application.
82
83Proceed to test as above.
84