zephyr/samples/net/sockets/dumb_http_server
Andy Ross 97fb8fa869 samples/net/sockets: Exclude intel_adsp boards
These are getting build failures due to some kind of devicetree
console definition missing.  These devices don't do networking, and
strictly don't even have a proper console device (logging is done via
a host mechanism).  Probably fixable.  Not worth the trouble.  Filter.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-09-03 07:19:34 -04:00
..
src net: buf: change avail_count variable to atomic type 2020-10-28 18:45:11 +02:00
CMakeLists.txt cmake: increase minimal required version to 3.20.0 2021-08-20 09:47:34 +02:00
Makefile.posix samples: net: sockets: Reinstate POSIX Makefiles. 2017-11-13 16:41:14 -05:00
overlay-e1000.conf ethernet/eth_e1000.c: change to new PCI(e) functions 2019-04-22 09:34:00 -07:00
overlay-netusb.conf samples: remove USB configuration option 2021-08-03 19:00:12 -04:00
overlay-qemu_cortex_m3_eth.conf samples: sockets: Add e1000 and stellaris ethernet drivers overlays 2019-03-26 07:29:40 -05:00
overlay-smsc911x.conf samples: sockets: Add eth_smsc911x overlays 2019-01-19 11:59:29 -05:00
overlay-zeroconf.conf samples: net: dumb_http_server: Add zero configuration 2019-10-04 10:24:56 +03:00
prj.conf samples: net: sockets: Convert to use new logging 2018-10-04 14:13:57 +03:00
README.rst samples: net: dumb_http_server: Using code block when needed 2019-10-16 16:47:37 +03:00
sample.yaml samples/net/sockets: Exclude intel_adsp boards 2021-09-03 07:19:34 -04:00

.. _sockets-dumb-http-server-sample:

Socket Dumb HTTP Server
#######################

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 for a host POSIX OS:

.. code-block:: console

    $ make -f Makefile.posix

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.