samples/net/sockets/echo/README.html · samples/net/sockets/echo/README.rst 공식 원문 ↗

Zephyr 3.7.0 · Samples · Networking · BSD sockets

Echo server (simple)

Port 4242에서 한 client씩 받아 line을 되돌려 보내고 같은 source를 POSIX host에서도 실행합니다.

Official pathsamples/net/sockets/echo/README.html
Source filesamples/net/sockets/echo/README.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

최소 BSD Sockets 구조, single-thread blocking 처리, Zephyr·POSIX build와 CC3220SF 실행 절차를 보존합니다.

Protocol

IPv4 · IPv6 · TCP

Server

Single-threaded

Port

4242

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 52EA5FCACBA550F7A3B44721E80D95C2CAB516F40989CFC9FDB773BB87276C16
.. zephyr:code-sample:: sockets-echo
   :name: Echo server (simple)
   :relevant-api: bsd_sockets

   Implements a simple IPv4/IPv6 TCP echo server using BSD sockets.

Overview
********

The sockets/echo sample application for Zephyr implements a TCP echo
server supporting both IPv4 and IPv6 and using a BSD Sockets compatible API.
The purpose of this sample is to show how it's possible to develop a sockets
application portable to both POSIX and Zephyr. As such, it is kept minimal
and supports only IPv4, IPv6 and TCP.

The source code for this sample application can be found at:
:zephyr_file:`samples/net/sockets/echo`.

Requirements
************

- :ref:`networking_with_host`
- or, a board with hardware networking

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

Build the Zephyr version of the sockets/echo application like this:

.. zephyr-app-commands::
   :zephyr-app: samples/net/sockets/echo
   :board: <board_to_use>
   :goals: build
   :compact:

After the sample starts, it expects connections at 192.0.2.1, port 4242.
The easiest way to connect is:

.. code-block:: console

    $ telnet 192.0.2.1 4242

After a connection is made, the application will echo back any line sent
to it. The application implements a single-threaded server using blocking
sockets, and thus can serve only one client connection at time. After the
current client disconnects, the next connection can proceed.

Running application on POSIX Host
=================================

The same application source code can be built for a POSIX system, e.g.
Linux. (Note: if you look at the source, you will see that the code is
the same except the header files are different for Zephyr vs POSIX.)

To build:

.. code-block:: console

    $ make -f Makefile.host

To run:

.. code-block:: console

    $ ./socket_echo

To test:

.. code-block:: console

    $ telnet 127.0.0.1 4242

As can be seen, the behavior of the application is the same as the Zephyr
version.

Running on cc3220sf_launchxl
============================

See the note on Provisioning and Fast Connect in :ref:`cc3220sf_launchxl`.

After having connected to an Access Point using the sample Wi-Fi shell,
the IP address will be printed to the console upon running this echo
application.

Proceed to test as above.

Part 3

한국어 전문 번역

개요

Zephyr의 sockets/echo sample application은 BSD Sockets 호환 API를 사용해 IPv4와 IPv6를 모두 지원하는 TCP echo server를 구현합니다.

이 sample의 목적은 POSIX와 Zephyr 양쪽에 이식할 수 있는 socket application을 개발할 수 있음을 보여 주는 것입니다. 따라서 IPv4, IPv6와 TCP만 지원하도록 최소한으로 구성했습니다.

이 sample application의 source code는 samples/net/sockets/echo에서 찾을 수 있습니다.

요구 사항

빌드 및 실행

Zephyr용 sockets/echo application은 다음과 같이 build합니다.

west build -b <board_to_use> samples/net/sockets/echo

Sample이 시작되면 192.0.2.1의 port 4242에서 connection을 기다립니다. 가장 간단한 연결 방법은 다음과 같습니다.

$ telnet 192.0.2.1 4242

Connection이 만들어지면 application은 전송된 모든 line을 그대로 되돌려 보냅니다. 이 application은 blocking socket을 사용하는 single-threaded server이므로 한 번에 client connection 하나만 처리할 수 있습니다. 현재 client가 연결을 끊어야 다음 connection이 진행됩니다.

POSIX Host에서 application 실행

동일한 application source code를 Linux 같은 POSIX system용으로 build할 수 있습니다. Source를 보면 Zephyr와 POSIX에서 header file만 다르고 나머지 code는 같습니다.

Build 방법:

$ make -f Makefile.host

실행 방법:

$ ./socket_echo

시험 방법:

$ telnet 127.0.0.1 4242

확인할 수 있듯이 application의 동작은 Zephyr version과 같습니다.

cc3220sf_launchxl에서 실행

cc3220sf_launchxl 문서의 Provisioning 및 Fast Connect 관련 참고 사항을 먼저 확인하십시오.

Sample Wi-Fi shell로 Access Point에 연결한 뒤 이 echo application을 실행하면 IP address가 console에 출력됩니다.

그 다음 앞에서 설명한 방법으로 시험합니다.

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.