[squeak-dev] Resuming a SocketStream after a ConnectionClosed exception?

Chris Muller asqueaker at gmail.com
Wed Feb 15 22:35:43 UTC 2017


Hi Tim,

> If anyone has suggestions on a better way to do this I’d be very happy to learn.

Not sure if it fits your model, but you might be interested in the
design employed by Ma client server (available on SM), which was
originally from John McIntosh.  Take a look at the MaServerSocket
class.

The idea is to never block any request processing based on network
activity with clients, whether sending or receiving, since that can be
slow.  All sends and receives are done in background Processes (but
never at the same time with a single client).

The server creates one Process per client for extracting request bytes from
them.  When all bytes of a request have been received from a client,
the chunk is added to a common 'requestQueue' (a SharedQueue) for all
clients.

Unlike other servers, Ma client server processes the requestQueue
serially, which saves the overhead of forking an extra Process for
every request, and since Smalltalk is single-threaded anyway, there's
no loss of throughput performance doing that.  After processing the
request, the sending of the response back to the client id done in a
separately forked background process.

It works well.  The Smalltalk code is kept as busy as it can be to
make sure its always waiting on the network, this maximizes the
server's throughput.

 - Chris


More information about the Squeak-dev mailing list