Squeak SmalltalkJoker Squeak Smalltalk : Network : prevnext Socket Process

Can anyone suggest how to write and debug a very simple use of sockets?

  My attempts at writing a remote invocation protocol have been
frustrated by inability to get two squeak processes to talk on the
same machine.
What does work is to start a server (PWS) in process 1, listening on
port 8000, then connecting via a client (Scamper) in process 2.
When I try my code in place of the client, it succeeds in connecting,
and a few times even got replies from the server, but more often it
just hangs, waiting for a reply.
Here's the code:
Transcript show: 'connected to addr: ',addr printString,' port: ',port
printString; cr.
 socket sendData: protocolHandler stream contents.
Transcript show: 'done'; cr.
Transcript show: 'QRMIMessage reading... '; cr.
 [socket isConnected] whileTrue: [
  (socket waitForDataUntil: (Socket deadlineSecs: 5)) ifFalse: [
   Transcript show: 'data was late'; cr
  ].
  bytes _ socket receiveDataInto: buf.
Transcript show: 'read:',bytes printString; cr.
  1 to: bytes do: [:i | serialization nextPut: (buf at: i)].
  totalBytes _ totalBytes + bytes.
 ].
And here is the typical Transcript output:
connected to addr: a ByteArray(127 0 0 1) port: 8000
done
QuATemplate reading...
data was late
read:0
....

Hi Richard!
Just a few hints "off the top of my head" without having looked at your
code:
1. Make sure the Processes yield to each other. For example I think you
should run them in lower priorities so that they get preempted by
another Process running in a higher prio. I think this was a good thing
to do IIRC.
2. You can play with the SharedStreams package to "emulate" Sockets. In
a previous project we built the SharedBidirectionalStream to work as a
replacement for SocketStream (a multi-demultiplexer so that multiple
connections could be run over a single socket).
Anyway, in that project we successfully had multiple unit tests setting
up servers and running clients from and to the same image - so it can
be done. But as I said - you might need to play with the Process prios.
Oh, yeah and btw, you should use SocketStream - no need to be messing
around at the Socket layer anymore IMHO.