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

Zephyr 3.7.0 · Samples · Networking · Socket service

Echo server (service)

Socket activity callback으로 thread 수와 memory 사용을 줄이며 IPv4·IPv6, UDP·TCP를 지원합니다.

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

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

Part 1

요약·해설

Socket service 개념, callback 동작과 현재 single-client 구현 제한을 명확히 구분합니다.

API

Socket service

Threads

One listener

Port

4242

Part 2

접을 수 있는 영어 원문 전체

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

   Implements a simple IPv4/IPv6 TCP echo server using BSD sockets and socket service API.

Overview
********

The sockets/echo_service 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 to use socket service API.
The socket service is a concept where many blocking sockets can be listened by
one thread, and which can then trigger a callback if there is activity in the set
of sockets. This saves memory as only one thread needs to be created in the
system.

The application supports IPv4 and IPv6, and both UDP and TCP are also supported.
The source code for this sample application can be found at:
:zephyr_file:`samples/net/sockets/echo_service`.

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

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

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

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

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

After the sample starts, it expects connections at 192.0.2.1, or 2001:db8::1
and 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 currently is only implemented to serve only one client connection
at time. After the current client disconnects, the next connection can proceed.

Part 3

한국어 전문 번역

개요

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

이 sample의 목적은 socket service API 사용법을 보여 주는 것입니다. Socket service는 하나의 thread가 여러 blocking socket을 listen하다가 socket set에 activity가 생기면 callback을 trigger하는 개념입니다. System에 thread 하나만 만들면 되므로 memory를 절약할 수 있습니다.

Application은 IPv4와 IPv6를 지원하며 UDP와 TCP도 모두 지원합니다. Source code는 samples/net/sockets/echo_service에서 찾을 수 있습니다.

요구 사항

빌드 및 실행

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

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

Sample이 시작되면 IPv4 address 192.0.2.1 또는 IPv6 address 2001:db8::1의 port 4242에서 connection을 기다립니다. 가장 간단한 연결 방법은 다음과 같습니다.

$ telnet 192.0.2.1 4242

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

Source

출처

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