Select Git revision
aes-set-key-internal.c
Forked from
Nettle / nettle
Source project has a limited visibility.
-
Niels Möller authoredNiels Möller authored
example3 9.59 KiB
3. This example is a very simple www-server.
For you who are not familiar with WWW (World Wide Web), it works by using
client program which will fetch files from remote servers when asked.
Usually by clicking a pitcure or text. This example is a program for the
server which will send files to any computer that requests them. The
protocol used to send the file is called HTTP. (HyperText Transfer Protocol)
Usually WWW involves HTML. HTML (HyperText Markup Language) is a way to
write documents with embedded pictures and links to other pages. These
links are normally displayed underlined and if you click them your WWW-
browser will load whatever document that link leads to.
#!/usr/local/bin/pike
/* A very small httpd capable of fetching files only.
* Written by Fredrik Hübinette as a demonstration of Pike.
*/
A comment, /* begins the comment, and */ ends it.
inherit "/precompiled/port";
Inherit copies all the functionality of /precompiled/port into this program.
/precompiled/port makes it possible to bind a TCP (Transmission Control
Protocol, the internet stanard for computer communication) socket to accept
incoming connections. A socket is simply a number to separate communications
to and from different programs on the same computer.
Next are some constants that will affect how uHTTPD will operate. This uses
the preprocessor directive #define. The preprocessor is the first stage in
the compiling process and can make textual processing of the code before
it is compiled. As an example, after the first define below, all occurances
of 'BLOCK' will be replaced with 16060.
/* Amount of data moved in one operation */
#define BLOCK 16060
/* Where do we have the html files ? */
#define BASE "/home/hubbe/pike/src/"
/* File to return when we can't find the file requested */
#define NOFILE "/home/hubbe/www/html/nofile.html"
/* Port to open */
#define PORT 1905
A port is a destination for a TCP connection. It is simply a number on the
local computer. 1905 is not the standard port for HTTP connections though,
which means that if you want to access this WWW server from a browser you
need to specify the port like this: http://my.host.my.domain:1905/
Next we declare a global variable of the type program called output_class,
and then we use the class construct to assign a program to it. class {}
defines a clonable program. (or class for you C++ freaks)
program output_class=class
{
inherit "/precompiled/file" : socket;
inherit "/precompiled/file" : file;
Our new class inherits /precompile/file twice. To be able to separate them
they are then named 'socket' and 'file'.
int offset=0;
Then there is a global variable called offset which is initalized to zero.
(each instance of this class will have it's own instance of this variable,
so it is not truly global, but..)
Note that the initalization is done when the class is cloned. (or