Small Talk
By Randal L. Schwartz
Last month, I introduced a quick-and-dirty load balancer by developing a short program to handle the basics, without getting into all the frills and whistles and gadgets that many full-blown solutions offer. This month, I decided to take on the Web chat arena in the same way.
This came about in part because of an email conversation among the columnists and staff of this magazine. The topic was this month's collaboration theme. Usually, I ignore the issue theme and write about whatever I want, but one suggestion was to write a Web chat server.
Via email, I said I could take on the idea, and one of the other columnists mentioned that he had already written a 200-line chat server and 100-line chat client in Perl for another publication. Yet another columnist mentioned that he had written such a program in Java, with some unspecified number of lines (probably far exceeding 300). Well, that gave me the challenge I needed: to write a Web chat system in under 100 lines. I succeeded.
Chit Chat
A few of the people who helped me test the system were clamoring for the source code, and so I present it here, in
Listing 1. As you can see, it's a server side script in Perl.
As for requirements, the chat system doesn't use any JavaScript. It works with any browser that supports frames and client-side pull (also known as meta-refresh). I even tested the script with the W3-mode in GNU Emacs and it works finethe only exception is that users have to refresh the viewing window manually.