There are currently three CGI (Common Gateway Interface) WebServer packages for Squeak, two available at the "CREATE" site under Applications. (CGI uses HTML forms to provide simple interaction on the Web. I use it for collaboration tools and surveys, and it can also be used for database access, guestbooks, shopping baskets, and a bunch of other things.) Tim Jones' (firstname.lastname@example.org), WebTalk, and Georg Gollmann's WebServer (email@example.com) (at http://ftp.tuwien.ac.at/~go/Squeak/webServer.html) are both really great. A new one is the Pluggable WebServer.
Georg's WebServer is a webserver oriented toward database applications. His Web page is where to go for the best information. I'll point out only a couple of strengths here:
WebTalk is actually three packages:
test1 "simple use of ensure:" [Transcript show: 'do this'] ensure: [Transcript show: ' then this';cr].
"simple use of ifCurtailed:" [Transcript show: 'do this'; cr] ifCurtailed: [Transcript show: 'but not this'; cr].
"ifCurtailed: within an on:do:" [[Transcript show: 'do this'. self signalDumbError. Transcript show: 'not this'] ifCurtailed: [Transcript show: ' and this']] on: Error do: [Transcript show: ' then this'; cr].
"handling more than one type of exception" [ self signalDumbError ] on: DumbError,StupidError do: [Transcript show: 'and finally this';cr]. "nested exception handlers" [[self signalDumbError ] on: StupidError do: [Transcript show: 'not this']] on: DumbError do: [ Transcript show: 'and this too';cr].
This class provides a high level interface to tcpip sockets. It uses stream protocol, and is implemented using ReferenceStreams so that it can work with any kind of object, not just characters. An example: server: c := Connection port: 1234. c nextPut: (c next storeString). c close.
client: c := Connection to: ''server.free.com'' port: 1234. c nextPut: #(a test). Transcript show: c next;cr.
Notice that only one side needs to use the close method, the other will close automatically when all data is read. Address can be specified using either names or dot notation "22.214.171.124".
By subclassing Connection you can create connection servers. For example, to create the EvaluationServer from Connection, the following method was added:
eventRead: aString self nextPut: (Compiler evaluate: aString)
To start the server, say the following:
EvaluationServer service: 1234 "the port number"
The server runs in the background and can handle any number of connections from any number of sources. To access the server, use code like the following:
c_Connection to: ''126.96.36.199'' port: 1234. c nextPut: ''2+2''. Transcript show: c next;cr. c nextPut: ''200 factorial''. Transcript show: c next;cr. c close.
To stop the server and close all current connections to it, say:
Also see the comment for StringConnection; it allows you to communicate with non-Smalltalk systems.
tim jones (firstname.lastname@example.org)
Extending the Existing WebServer Tools
The CGI WebServer packages provided by Tim Jones (email@example.com), WebTalk, and by Georg Gollmann (firstname.lastname@example.org) (at http://ftp.tuwien.ac.at/~go/Squeak/webServer.html) are really great, but they focus on serving CGI scripts from inside of Squeak. I also wanted to serve HTML, GIF, and JPEG files. The downloads below provide subclasses which add file access capabilities to these tools. Thanks to the efforts of John Maloney, Tim, and Georg, these have become quite stable on the various Macs I've tried them on (e.g., longest run without problems has been about four days, before I had to restart the machine for other reasons), using both 1.20 and 1.22 versions of Squeak and respective versions of WebTalk and WebServer.
For Tim's WebTalk -- No longer necessary, but will still work: WTWebServer.st is the WebServer that works with Tim's WebTalk.
For Georg's WebServer: FullWebServer.st is the WebServer that works with Georg's WebServer.
[FullWebServer serveOnPort: 8081 loggingTo: 'log10-1.txt'] fork
"More About Squeak..."
Last modified at 1/30/98; 10:05:51 AM
Home Page for How To Squeak
Other Links of Interest
College of Computing | EduTech Institute | GVU Center
Mark Guzdial | CS2390, Modeling and Design | STABLE
Last modified at 1/30/98; 10:05:51 AM