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.
It will implement the HTTP 1.0 protocol with the GET, HEAD and POST methods. This will be enough to support the posting of forms.
Part of the URL hierarchy will be mapped directly to a directory hierarchy as in Apache.
CGI-BIN scripts will be supported.
Built-in URL handlers will be supported providing a simple servlet capability.
There will be enough functionality to support forms via CGI.
Multiple concurrent connections will be supported. But there will only be one server process.
Only one language will be supported, English.
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.