Chapter 8. The Swerve Web Server

Table of Contents
Introduction
The HTTP Protocol
The Resource Store
Server Configuration
The Architecture of the Server
Building and Testing the Server

Introduction

I am now going to work through the design and implementation of a simple web server in CML, which I'll call Swerve. As well as being a good programming example it can be used as the basis for SML applications with a web interface.

The server will have the following features.

There are several similar projects around. The Fox Project has the aim of studying the application of advanced languages, in particular SML, to networks and operating system software. As a demonstration they have developed an implementation of a TCP/IP protocol stack along with a web server to show it off, see [FoxNet]. Everything is implemented in SML except the network device driver. The TCP/IP stack makes extensive use of functors to plug together the various layers of the protocol stack producing an efficient implementation.

Another web server, but not in SML, is MIT's Common Lisp Hypermedia Server, see [CLHTTP]. It is a full-featured web server written in Common Lisp. It is used as the framework for web interfaces to some of their artificial intelligence projects as well as a few commercial projects. With more work the Swerve server could be useful for similar projects written in SML.

Yet another web server, written in Haskell and using the language's concurrent features, is described in [HaskellServer]. More information on using Haskell for concurrent programming can be found in [AwkwardSquad].

Another example of a server written in SML is the ACAP daemon which is part of the Cyrus e-mail system, see [ACAPD]. This implements a remote store for address books, book marks etc. according to RFC2244. It uses CML and SML/NJ so it is useful as another point of view on using CML.