Part 1
요약·해설
Dual-stack endpoint, NUM_FDS 제한, Zephyr·POSIX 실행 절차를 원문 구조대로 보존합니다.
select()
Non-blocking
Up to 3
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
BA03FE8E557F0985496086FE1C8D4994FAB737F0D68467740EDC98625AA83CFC
.. zephyr:code-sample:: async-sockets-echo-select
:name: Asynchronous echo server using select()
:relevant-api: bsd_sockets
Implement an asynchronous IPv4/IPv6 TCP echo server using BSD sockets and select()
Overview
********
The sockets/echo_async_select sample application for Zephyr implements an
asynchronous IPv4/IPv6 TCP echo server using a BSD Sockets compatible API
with non-blocking sockets and a ``select()`` call. This is a variant of
the :zephyr:code-sample:`async-sockets-echo` sample.
The source code for this sample application can be found at:
:zephyr_file:`samples/net/sockets/echo_async_select`.
Requirements
************
- :ref:`networking_with_host`
- or, a board with hardware networking (including 6LoWPAN)
Building and Running
********************
Build the Zephyr version of the sockets/echo_async application like this:
.. zephyr-app-commands::
:zephyr-app: samples/net/sockets/echo_async_select
:board: <board_to_use>
:goals: build
:compact:
After the sample starts, it expects connections at 192.0.2.1 (IPv4), or
2001:db8::1 (IPv6), port 4242. The easiest way to connect is:
.. code-block:: console
$ telnet 192.0.2.1 4242 # use this for IPv4
$ telnet 2001:db8::1 4242 # or this for IPv6
After a connection is made, the application will echo back any line sent to
it. Unlike the :zephyr:code-sample:`sockets-echo` sample, this application
supports multiple concurrent client connections. You can open
another terminal window and run the same telnet command as above.
The sample supports up to three connected clients, but this can be adjusted
by changing ``NUM_FDS`` defined in the source code.
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, and
there's an additional option to set for Linux to make a socket IPv6-only).
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 # use this for IPv4
$ telnet ::1 4242 # or this for IPv6
As can be seen, the behavior of the application is the same as the Zephyr
version.
Part 3
한국어 전문 번역
개요
Zephyr의 sockets/echo_async_select sample application은 non-blocking socket과 select() call을 사용하는 BSD Sockets 호환 API로 asynchronous IPv4/IPv6 TCP echo server를 구현합니다.
이 application은 poll() 기반 asynchronous echo sample의 변형입니다.
이 sample application의 source code는 samples/net/sockets/echo_async_select에서 찾을 수 있습니다.
요구 사항
- Host system과 networking
- 또는 6LoWPAN을 포함한 hardware networking 기능이 있는 board
빌드 및 실행
Zephyr용 sockets/echo_async_select application은 다음과 같이 build합니다.
west build -b <board_to_use> samples/net/sockets/echo_async_select
Sample이 시작되면 IPv4 address 192.0.2.1 또는 IPv6 address 2001:db8::1의 port 4242에서 connection을 기다립니다. 가장 간단한 연결 방법은 다음과 같습니다.
$ telnet 192.0.2.1 4242 # use this for IPv4
$ telnet 2001:db8::1 4242 # or this for IPv6
Connection이 만들어지면 application은 전송된 모든 line을 그대로 되돌려 보냅니다. Simple sockets/echo sample과 달리 이 application은 여러 concurrent client connection을 지원합니다. 다른 terminal window를 열고 같은 telnet 명령을 다시 실행할 수 있습니다.
Sample은 연결된 client를 최대 세 개까지 지원합니다. 이 수는 source code에 정의된 NUM_FDS를 변경해 조정할 수 있습니다.
POSIX Host에서 application 실행
동일한 application source code를 Linux 같은 POSIX system용으로 build할 수 있습니다. Source를 보면 Zephyr와 POSIX에서 header file이 다르며, Linux에는 socket을 IPv6-only로 설정하기 위한 추가 option이 있다는 점을 제외하면 code는 같습니다.
Build 방법:
$ make -f Makefile.host
실행 방법:
$ ./socket_echo
시험 방법:
$ telnet 127.0.0.1 4242 # use this for IPv4
$ telnet ::1 4242 # or this for IPv6
확인할 수 있듯이 application의 동작은 Zephyr version과 같습니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.