Tcl HomeTcl Home Hosted by
ActiveState

Google SiteSearch

The current version is 3.5.1 May 27, 2004.
The current TclHttpd bundle includes:
  • TclHttpd 3.5.1
  • Tcl 8.4.5
  • Thread 2.5.2
  • Tcllib 1.6

New TclHttpd 3.5.1 Starkit

Tcl is one of my preferences for both simple and complex programming tasks. Brent Welch's web server based on Tcl is one of the most inspired and inspiring tools I've had occasion to work with. A real *tool*, not just another application. - Lucio De Re

What is the Tcl Web Server? It is a pure-Tcl implementation of an HTTP protocol server. It runs as a script on top of a vanilla Tcl interpreter. Early versions worked with Tcl versions 7.5 and higher, but the latest requires Tcl 8.*.

How does it work? The Tcl I/O system provides event-driven I/O facilities and a primitive that copies data from one I/O channel to another. The server does the HTTP protocol handling and then simply directs the I/O system to blast data from disk to a network socket. The Tcl runtime handles all the I/O in a non-blocking fashion so the server easily multiplexes multiple clients without the complexities of threading. The server has suprisingly good performance because of Tcl's sophisticated I/O system.

Why is it interesting? The HTTP protocol is perhaps the least interesting aspect of the server. The cool stuff is the framework for generating dynamic page content, and the support for embedding the server directly into legacy applications to "web-enable" them.

From a technical standpoint, a Tcl-based web server is ideal for embedding because Tcl was designed to support embedding into other applications. The interpreted nature of Tcl allows dynamic reconfiguration of the server. Once the core interface between the web server and the hosting application is defined, it is possible to manage the web server, upload Safe-Tcl control scripts, download logging information, and otherwise debug the Tcl part of the application without restarting the hosting application.

How do you use it?

I have started to hear of many uses of Tcl Httpd. Let us know about your use so we can list sample applications.

Basic Features

As a stand-alone application, the Tcl web server supports these basic server features:

  • CGI. The standard CGI interface is supported. However, there is high overhead in CGI because of the cost of spawning an external process to handle each request. The server provides alternatives described later.
  • Server-side include. The NCSA include facility is supported so you can compose a page from various parts, statically. Again, this is not always the best approach, but we support it.
  • Basic Authentication. This is the "scrambled password" standard that is widely used even though it is relatively easy to crack if you can watch network packets. Support for SSL is planned and will be incorporated based on customer demand. SSL provides strong authentication between the client and the server as well as encryption of data.
  • Image Maps. Image maps are processed directly by the server to reduce processing overhead.
  • Standard logging and monitoring facilities.
  • HTTP 1.0 and HTTP 1.1 keep-alives for efficient use of socket resources.

Advanced Features

The server architecture lets the application plug into the URL processing path at several locations. Many standard modules are provided, and you can mix and match modules and provide your own in order to build a fully custom server. These are the hook points:

  • Handlers for whole sub-trees of the URL hierarchy. For example, /status and /debug are implemented by the server itself to provide live status pages and debugging hooks. /cgi-bin is another example.
  • Handlers for different document types. You can define a Tcl procedure to process files of certain types before data is returned to the client.
  • Handlers for authentication schemes.
  • The server also supports a template-based system for dynamic page generation. This includes support for session semantics.
  • SNMP integration. The server can generate pages containing information from SNMP MIBs, and forms that let you configure SNMP devices. This uses the Scotty network management extension for Tcl.
  • The server works nicely with TclPro/ActiveState Debugger to let you debug your web applications.
  • Tcl libraries to facilitate the implementation of Application-Direct URLs by OEMs.
  • SSL via the TLS Tcl extension.

Availability

Latest Release: 3.5.1 May 27, 2004

See also the TclHttpd SourceForge project for file distributions.

The Tcl web server is being made freely available. You can download the server (compressed tar file) (zip file), and for SNMP you also need the Scotty network management Tcl extention.

The Tcl/TclHttpd/TclLib/Thread (gzip) (zip) bundled distribution gives you:

  • TclHttpd - the web server source.
  • Tcl/Tk - a compatible version of Tcl/Tk
  • TclLib - a compatible release of the Standard Tcl Library
  • Thread - A C-level extension that adds threads to Tcl.
  • And build scripts to put everything together.

The TclHttpd Starkit distribution includes the server code, the required TclLib modules, and a sample document tree in a single file for easy deployment. Just run the starkit with the TclKit interpreter. It takes all the same command line arguments as bin/httpd.tcl. Using the sdx tool that wraps and unwraps Starkits, you can assemble your own custom TclHttpd application Starkit.

About SSL

For https/SSL service, you need to use the TLS extension by Matt Newman and either OpenSSL or the BSAFE libraries. You need TLS 1.4 and Tcl 8.3.2 for reliable performance.

I collect patches and enhancements to the server. If you use the server and fix it or add something cool you want to share, please let us know at [email protected].

The current sources are visible at the netCVS repository.

You can benefit from some of the advanced features like the site wide consistent design exhibited on this site by using the Tcl Template mechanism, libraries and standalone converter: alpha release tml10a2-src.tar.gz or tml10a2-src.zip). If this standalone support for automatic html page generation interests you, contact [email protected].