Chapter 14. Internetworking with gawk

This chapter describes gawk’s networking features in depth, including a number of interesting examples and the reusable core of a gawk-based web server. The chapter is adapted from TCP/IP Internetworking with gawk , by Jürgen Kahrs and Arnold Robbins, which is a separate document distributed with gawk.

Networking with gawk

The awk programming language was originally developed as a pattern-matching language for writing short programs to perform data manipulation tasks. awk’s strength is the manipulation of textual data that is stored in files. It was never meant to be used for networking purposes. To exploit its features in a networking context, it’s necessary to use an access mode for network connections that resembles the access of files as closely as possible.

awk is also meant to be a prototyping language. It is used to demonstrate feasibility and to play with features and user interfaces. This can be done with file-like handling of network connections. gawk trades the lack of many of the advanced features of the TCP/IP family of protocols for the convenience of simple connection handling. The advanced features are available when programming in C or Perl. In fact, the network programming in this section is very similar to what is described in books such as Internet Programming with Python, Advanced Perl Programming, and Web Client Programming with Perl (O’Reilly).

However, you can do the programming here without first having to learn ...

Get Effective awk Programming, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.