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

Zephyr 3.7.0 · Samples · Networking · BSD sockets

Dumb HTTP server

IPv4 port 8080에서 static page를 제공하고 curl·Apache Bench·POSIX host build로 동작을 시험합니다.

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

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

Part 1

요약·해설

Minimal request 처리, 192.0.2.1 endpoint, 10-request load test와 POSIX 이식성을 보존합니다.

Response

Single static page

Endpoint

192.0.2.1:8080

Portable

Zephyr · POSIX

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 5B5B0A13B26CDE84155332264C43C54BA8AAE97C2F8180A01D7041D238A74027
.. zephyr:code-sample:: socket-dumb-http-server
   :name: Dumb HTTP server
   :relevant-api: bsd_sockets net_pkt

   Implement a simple, portable, HTTP server using BSD sockets.

Overview
********

The sockets/dumb_http_server sample application for Zephyr implements a
skeleton HTTP server 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, this HTTP server example is
kept very minimal and does not really parse an incoming HTTP request,
just reads and discards it, and always serve a single static page. Even
with such simplification, it is useful as an example of a socket
application which can be accessed via a conventional web browser, or to
perform performance/regression testing using existing HTTP diagnostic
tools.

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

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/dumb_http_server
   :board: <board_to_use>
   :goals: build
   :compact:

After the sample starts, it expects connections at 192.0.2.1, port 8080.
The easiest way to connect is by opening a following URL in a web
browser: http://192.0.2.1:8080/ . You should see a page with a sample
content about Zephyr (captured at a particular time from Zephyr's web
site, note that it may differ from the content on the live Zephyr site).
Alternatively, a tool like ``curl`` can be used:

.. code-block:: console

    $ curl http://192.0.2.1:8080/

Finally, you can run an HTTP profiling/load tool like Apache Bench
(``ab``) against the server::

    $ ab -n10 http://192.0.2.1:8080/

``-n`` parameter specifies the number of HTTP requests to issue against
a server.

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_dumb_http

To test, connect to http://127.0.0.1:8080/ , and follow the steps in the
previous section.

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

Part 3

한국어 전문 번역

개요

Zephyr의 sockets/dumb_http_server sample application은 BSD Sockets 호환 API로 skeleton HTTP server를 구현합니다.

이 sample의 목적은 POSIX와 Zephyr 양쪽에 이식할 수 있는 socket application을 개발하는 방법을 보여 주는 것입니다. 따라서 HTTP server example은 매우 작게 유지하며, 들어오는 HTTP request를 실제로 parse하지 않고 읽어서 버린 뒤 항상 static page 하나만 제공합니다.

이렇게 단순화했지만 일반 web browser로 접근 가능한 socket application example로 유용하며, 기존 HTTP diagnostic tool을 이용한 performance/regression testing에도 사용할 수 있습니다.

Source code는 samples/net/sockets/dumb_http_server에 있습니다.

요구 사항

빌드 및 실행

Zephyr version의 application은 다음처럼 build합니다. 공식 원문은 이를 sockets/echo application이라고 적지만 실제 sample path는 sockets/dumb_http_server입니다.

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

Sample이 시작되면 192.0.2.1의 port 8080에서 connection을 기다립니다. 가장 쉬운 방법은 browser에서 http://192.0.2.1:8080/을 여는 것입니다.

특정 시점의 Zephyr website에서 가져온 sample content가 표시됩니다. 따라서 현재 Zephyr site 내용과 다를 수 있습니다. 대신 curl을 사용할 수도 있습니다.

$ curl http://192.0.2.1:8080/

Apache Bench(ab) 같은 HTTP profiling/load tool도 server에 실행할 수 있습니다.

$ ab -n10 http://192.0.2.1:8080/

-n parameter는 server에 보낼 HTTP request 수를 지정합니다. 이 example은 10개 request를 보냅니다.

POSIX Host에서 application 실행

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

Build 명령:

$ make -f Makefile.host

실행 명령:

$ ./socket_dumb_http

시험하려면 http://127.0.0.1:8080/에 연결하고 앞 절의 단계를 따릅니다. Application 동작은 Zephyr version과 같습니다.

Source

출처

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