VASmalltalk – another communication library

In my last posting I wrote, that I was investigating MessagePak-RPC as a solution for my service network.

I stopped work on that, because I implemented MessagePak-RPC in Smalltalk in a way all the other programming language bindings did not do. I made it more powerful, but the reference implementation showed me, that I interpreted the protocol in a more powerful – but wrong – way. They are considering to extend their protocol into the directon of my interpretation, but up to now it does not fullfill my needs.

Then I found ZMQ and wrote a wrapper for that c communication library – and I like this library very much.

I wanted to implement the example of this video.

I found a GnuSmalltalk implementation at the zmq home page, but I have to admit, that I did not like that and wrote my own wrapper – and it showed me, how much more powerful VASmalltalk could be/is.

The demos in that video are presented using Lua in two different windows. Due to the asynchronous support in VA the example can be executed in the same image, but the sending code has to be forked in a specific Smalltalk thread.

Here is my first demo code.This one is executes in a first workspace (its the server).

context := ZMQCore newContext: 1.
socket := context downstreamSocket.
socket bindTo: 'tcp://'.
[ socket send: 'Hello' ] fork

…and this code is executed in a second workspace (its a client):

context := ZMQCore newContext: 1.
socket := context upstreamSocket.
socket connectTo: 'tcp://'.
[ [ true ] whileTrue:[ Transcript cr; show: '1: ',socket receive ] ] fork

The best thing here is, that you actually even do not need the socket library of VASmalltalk and most of the communication are done in external OS threads – therefore leaving much more CPU execution time to Smalltalk code itselfs and you may be even using several cores of your CPU.

This entry was posted in Smalltalk and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s