.. _Extended4CGI:

.. raw:: html

   <script>ODSA.SETTINGS.DISP_MOD_COMP = true;ODSA.SETTINGS.MODULE_NAME = "Extended4CGI";ODSA.SETTINGS.MODULE_LONG_NAME = "Extended Example: CGI Web Server";ODSA.SETTINGS.MODULE_CHAPTER = "Networked Concurrency"; ODSA.SETTINGS.BUILD_DATE = "2021-06-01 12:51:47"; ODSA.SETTINGS.BUILD_CMAP = false;JSAV_OPTIONS['lang']='en';JSAV_EXERCISE_OPTIONS['code']='java';</script>


.. |--| unicode:: U+2013   .. en dash
.. |---| unicode:: U+2014  .. em dash, trimming surrounding whitespace
   :trim:


.. This file is part of the OpenCSF eTextbook project. It was
.. auto-generated by scripts from the OpenDSA eTextbook project.
.. See https://OpenCSF.org for more details. OpenCSF is distributed
.. under a Creative Commons Attribution-NonCommercial 4.0 International
.. License (see http://creativecommons.org/licenses/by-nc/4.0/),
.. Copyright (c) 2019-2021 by Michael S. Kirkpatrick. OpenDSA is
.. distributed under an MIT open source license, Copyright (c) 2012-2021
.. by the OpenDSA Project Contributors.

.. avmetadata::
   :author: Michael S. Kirkpatrick
   :requires:
   :satisfies: 
   :topic: 

Extended Example: CGI Web Server
================================

This Extended Example creates a web server for processing requests using the *common gateway
interface* (CGI). In a standard web server, HTML files are stored on the file system and their
contents are sent through the socket when requested. With CGI, the server can execute a compiled
program. Whatever the program writes to its standard output gets redirected through the socket to
the client. This technique supports dynamic server-side execution, such as generating HTML based on
database query results.

.. codeinclude:: Sockets/ExtEx-4.c
   :linenos: true

|

.. codeinclude:: Sockets/CGI.c
   :linenos: true

