3 Some Applications and Techniques

In this chapter, we look at a number of self-contained scripts, with an emphasis on concise networking. Along the way, we work towards creating building blocks that encapsulate often-needed functions of the networking world, show new techniques that broaden the scope of problems that can be solved with gawk, and explore leading edge technology that may shape the future of networking.

We often refer to the site-independent core of the server that we built in A Simple Web Server. When building new and nontrivial servers, we always copy this building block and append new instances of the two functions SetUpServer() and HandleGET().

This makes a lot of sense, since this scheme of event-driven execution provides gawk with an interface to the most widely accepted standard for GUIs: the web browser. Now, gawk can rival even Tcl/Tk.

Tcl and gawk have much in common. Both are simple scripting languages that allow us to quickly solve problems with short programs. But Tcl has Tk on top of it, and gawk had nothing comparable up to now. While Tcl needs a large and ever-changing library (Tk, which was originally bound to the X Window System), gawk needs just the networking interface and some kind of browser on the client’s side. Besides better portability, the most important advantage of this approach (embracing well-established standards such HTTP and HTML) is that we do not need to change the language. We let others do the work of fighting over protocols and standards. We can use HTML, JavaScript, VRML, or whatever else comes along to do our work.