NAME -- Webserver example, using Perl's medium level API for network access


    ./ 2345


This is just a simple http server for CS629, Programming Assignment #3. The program takes only one argument, and that is the port number to run on. Note that only the very basics of HTTP/1.0 are implemented.

You may set the variable DOCUMENT_ROOT to the base directory of the webserver. The default is public_html in your home directory. is written in what I consider as ``medium level API'' for network access.

low level API

Basic network calls, just as in C.

medium level API

Simplified access through modules, as in Java.

high level API

Configurable HTTP Deamon, just as the Perl module HTTP::Daemon.


The following examples assumes that the webserver is run on, port 2345 and that DOCUMENT_ROOT is set in the script to the path where the following index.html is in. A form may look like this one.

Hello world!
This is a checkbox
A radio group
Radio 1
Radio 2
A single selection
A multiple selection

The code for the form in index.html is as follows.

        Hello world!
        <form method="POST" action= >
        <dd>First: <input type="text" name="first" value="Ron"><br>
        Last: <input type="text" name="last" value="Blaschke">
        <dt>This is a checkbox
        <dd><input type="checkbox" name="check">CheckMe!
        <dt>A radio group
        <dd><input type="radio" name="radio" value="radio1" checked>Radio 1<br>
            <input type="radio" name="radio" value="radio2">Radio 2
        <dt>A single selection
        <dd><select size="2" name="select-single">
             <option selected>A</option>
        <dt>A multiple selection
        <dd><select size="4" name="select-multiple" multiple>
             <option selected>1</option>
             <option selected>2</option>
        <input type="submit" name="Submit">

Make sure that the action points to the webserver address!

Now we start the webserver.

    >./wserv_med 2345
    Starting httpd on port 2345

Access the page with a webbrowser. The webbrowser will show the form, the server will output something like this:

    1: 'GET /index.html HTTP/1.0'
    2: 'Connection: Keep-Alive'
    3: 'User-Agent: Mozilla/4.61 [en] (Win95; I)'
    4: 'Host:'
    5: 'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*'
    6: 'Accept-Encoding: gzip'
    7: 'Accept-Language: en'
    8: 'Accept-Charset: iso-8859-1,*,utf-8'
    9: ''

Enter data in the form and press ``Submit Query''. The server will output something similar to this.

    1: 'POST /index.html HTTP/1.0'
    2: 'Referer:'
    3: 'Connection: Keep-Alive'
    4: 'User-Agent: Mozilla/4.61 [en] (Win95; I)'
    5: 'Host:'
    6: 'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*'
    7: 'Accept-Encoding: gzip'
    8: 'Accept-Language: en'
    9: 'Accept-Charset: iso-8859-1,*,utf-8'
    10: 'Content-type: application/x-www-form-urlencoded'
    11: 'Content-length: 108'
    12: ''
    form data is:
    first = 'Ron'
    last = 'Blaschke'
    radio = 'radio1'
    select-single = 'A'
    select-multiple = '1'
    select-multiple = '2'
    Submit = 'Submit Query'

And the webbrowser will show something like this.

Hi Ron Blaschke! Your request is processed.

Your choice was:


Socket, IO::Socket, HTTP::Daemon, RFC1945 (HTTP/1.0), RFC2616 (HTTP/1.1)


none known


Ronald Blaschke <>


(c)1999 by Ronald Blaschke <>