first release of my networking framework available

Craig Latta Craig.Latta at NetJam.ORG
Sat Jan 9 04:33:11 UTC 1999


Hi--

	The first release (one alpha one) of my networking framework is available, from http://www.netjam.org/self/projects/smalltalk/correspondents.html. It's described there, and below. The source comes from another system and doesn't work in Squeak yet; I intend this release to describe the architecture and message interfaces. 

	Feedback is very much appreciated!


	thanks,

-C

***

correspondents: 
a new networking framework for Squeak 


	I've written a new networking framework for Squeak. For reference, I'll call it the 
"correspondents" framework. 

	This is release one alpha one. It doesn't work. It comes from a working system which forked from
Squeak 1.13, and is an unintegrated set of the most important classes and methods. I intend it to
provide a rough overview of the architecture and message interfaces. I recommend against
installing it unless you want to hack on it. Instead, browse it with the package browser ("browse
code" from the file menu of the file list). The primitive numbers used are for the forked system,
and will change (or become "pluggable"). 

	I intend to get everything working in the latest available Squeak, eventually. 

	Brief discussions of the classes follow, including highlights of coming attractions. The
parenthesized numbers indicate the priorities I've given to integrating each class. Only those with
priority one appear in this release. 


	The primary classes are those of the Correspondent hierarchy: 

   Correspondent (1)
      Client (1)
         HTTPClient (3)
         IdentificationClient (4)
         IRCClient (4)
         MIDIClient (3)
         NNTPClient (3)
         POPClient (2)
         RemoteFileStreamClient (3)
         SerialCorrespondent (1)
            VISCAClient (3)
            X10Client (2)
         SMTPClient (2)
         TelnetClient (5)
         TimeClient (3)
      Server (1)
         HTTPServer (3)
         IdentificationServer (4)
         MIDIServer (3)
         RemoteFileStreamServer (3)
         TFTPServer (2)

	Correspondent, Client, SerialCorrespondent, and Server do the busywork involved in writing
clients and servers. Transport details are encapsulated by NetStreams (described below).
Correspondent authors can focus on protocol details, with a streamy message interface, instead

of transport details. 

	It's straightforward to combine multiple correspondents in an "application". For example, a
mailer would probably use multiple POPClients and SMTPClients. 

	RemoteFileStreamClient and RemoteFileStreamServer constitute a network file system.
MIDIClient and MIDIServer are the beginnings of the NetJam distributed music system. 


	I rewrote the Stream hierarchy:

   Stream (1)
      PositionableStream (1)
         WriteableStream (1)
            DiscardingStream (2)
            ExternalStream (1)
               FileStream (2)
                  AppendingFileStream (2)
                  AppendingFileStreamWriter (2)
                  RemoteFileStream (2)
               NetStream (1)
            NetMessage (1)
               EmailMessage (2)
               NewsMessage (3)
            RingBuffer (2)
               InfiniteRingBuffer (2)
            TextStream (2)
         RandomNumberStream (2)

	I was originally motivated by the need to get a filesystem working on custom hardware. The
existing Squeak filesystem support (including the Stream hierarchy) was cumbersome, with a lot
of unreachable and redundant code and an overly-complicated class factoring. The new factoring
is much simpler, unifies all "external" resources with the ExternalStream hierarchy, and has
smarter buffering. 

	The NetMessage hierarchy extends stream protocol to the creation of email and news 
messages, minimizing copying. 


	External resources are named by Universal Resource Locators (URLs): 

   URL (2)
      HostBasedLocator (2)
         Filename (2)
         Maildrop (2)
      MessageLocator (2)


	All low-level access to the outside world is factored into one hierarchy: 

   ExternalResource (1)
      File (2)
      InternetSocketAddress (1)
      MIDIInstrument (2)
      NetResource (1)
         InternetSocket (1)
            TCPSocket (1)
               ClientTCPSocket (1)
                  IncomingClientTCPSocket (1)
                  OutgoingClientTCPSocket (1)
               ServerTCPSocket (1)
            UDPSocket (1)
         InternetSocketAddressResolver (1)
         SerialPort (1)

	All external resources support an interface which makes them suitable for use as collections for
NetStreams. 

	File will probably have subclasses to account for host platform differences. The support for
sockets is significantly different than that currently in Squeak. The main differences are a
Berkeley-style primitive interface, and synchronization based on (Smalltalk) semaphores, instead
of the current busy-waiting. Timeouts are supported via those semaphores. The sockets support
also uses threads at the virtual machine level. The external resources framework uses
fixed-address objects extensively. I'll release support for that after I get a grip on the current
state of memory management in Squeak (in light of several other memory management changes
my group may propose). I'll release the primitive sources in a subsequent release, after some
cleanup. 


	Exception-handling is used in many places by the classes above, usually for "ensured behavior".
For example, one may open a file stream and write to it, ensuring that the file will be closed
despite interruptions. Exception-handling is supported by three classes, Exception (1), Situation
(1), and HandlerCollection (1), all subclasses of Object. Ensured blocks for work blocks with
explicit returns ("non-local returns") execute properly, without virtual machine support. I take an
instance-based approach, as opposed to ANSI's class-based one. It would be straightforward to
write an ANSI-compatible interface. The exception-handling framework requires scope-aware
closures to work properly. I'm working on that.


--
Craig Latta
composer and computer scientist
craig.latta at netjam.org
www.netjam.org
latta at interval.com
Smalltalkers do: [:it | All with: Class, (And love: it)]





More information about the Squeak-dev mailing list