[squeak-dev] documentation on squeak vm api
johnmci at smalltalkconsulting.com
Thu Oct 16 17:58:42 UTC 2008
On Wed, Oct 15, 2008 at 10:34 PM, Kjell Godo <squeaklist at gmail.com> wrote:
> I have noticed that Squeak seems to do Sockets by using Delays for x
> milliseconds and then waking back up to do something again.
Well that is wrong, it just appears that way. As the guy who wrote the vm
socket semphore logic, let me explain, there are three smaltalk semphores on
a socket, (read, write, control) which means on a socket state change you
would get the control sempahore signaled, on a connection accepted, a socket
close, a connection error, and a connection reset.
The read semaphore is signalled when data arrives for the socket.
The write sempahore is signalled when the data is written, which does not
mean the data is received by the other party.
This is rather complicated, and an failed attempt was made by Craig Latta to
re-implement all this with a product he called "Flow" which he introduced
aug 17th of 2002.
Now for example if you wanted to read from a socket you would call the read
data available primitive primSocketReceiveDataAvailable:, discover no data,
and then what? Wlll you wait *forever*? for the read semaphore to be
signalled? Well yes, maybe no. For the no case you have Smalltalk code that
waits on the read semaphore for so many seconds then fails, then the error
recovery does whatever action the programmer decided to do, well like try
again? Plus of course then handle issues like the socket being closed.
John M. McIntosh <johnmci at smalltalkconsulting.com>
Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev