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