Squeak Socket Primitives

Stewart MacLean stewart.maclean at nzhis.govt.nz
Fri Nov 12 05:09:11 UTC 1999


Hi Guys,

been scanning this thread with interest. I'm experienced with Smalltalk but
not so much with Squeak, however this might be of interest.

Years ago I wrote an interface to OS/2's NamedPipes to experiement with
inter image object transfer, using VSE. One could make the calls blocking or
non blocking and indeed if I called in blocking mode, Smalltalk would
freeze.

The solution was to use an addon; the so called Non-Blocking API feature. It
basically made the call, (which was done in a separate Smalltalk process
which I blocked using a semaphore), continued with Smalltalk and once the
call unblocked, an interupt hooked back into the original call to signal the
semaphore, and unblock the Smalltalk process. It was sometime ago and I had
to reboot my machine many times to get this working, however it gave me an
insight as to how Smalltalk and the OS interact. I've also had similar
experiences calling into ELHAPI, a terminal emulator, from VisualAge. It's
hairy, but non-blocking API calls from Smalltalk are possible, but
complicated!

Keep up the discussion - thats how we all learn!

Cheers - have a good weekend.

Stewart 

> -----Original Message-----
> From: Raab, Andreas [mailto:Andreas.Raab at disney.com]
> Sent: Friday, November 12, 1999 12:06 PM
> To: Craig Latta
> Cc: recipient.list.not.shown; @cs.uiuc.edu
> Subject: RE: Squeak Socket Primitives
> 
> 
> Craig,
> 
> > > recv() and send() are called directly from the primitive, e.g.,
> > > recv() from nextIntoStartingAtTCPSocket and send() from 
> > > nextPutFromStartingAtTCPSocket - unless you have changed the 
> > > primitives over the last two days. If any of these calls 
> > block your VM 
> > > stands still and does absolutely nothing!
> > 
> > 	I am AMAZED that you wrote that. Look at the code 
> > again. Those calls WON'T block, because, by design, any 
> > waiting that was necessary has ALREADY BEEN DONE. That's the 
> > WHOLE POINT.
> 
> Okay, so here is the proof (perhaps then you stop using 
> capital letters but
> start thinking again). Execute the following code from a workspace ...
> 
> 	"Server accepting single connection (using Squeak prims)"
> 	Socket initializeNetwork.
> 	server _ Socket newTCP.
> 	server listenOn: 22334.
> 
> 	"Client pushing data (using Correspondants prims)"
> 	client _ NetStream tcpClientToPort: 22334 atHostNamed: 
> 'localhost'.
> 	client nextPutAll: (String new: 100000). "<- This will block!"
> 
> ... and your Squeak stands forever. Now where is the whole 
> point here?!
> 
> > 	Code please?
> 
> As soon as I have done some cleanup.
> 
>   Andreas
> 





More information about the Squeak-dev mailing list