0MQ Binding


[ZeroMessageQueue (0MQ) messaging library binding with Red/System programming language] ZeroMessageQueue (0MQ) is a library that provides a flexible messaging subsystem. Here you can find three bindings that make 0MQ available from the Red/System, REBOL 3 and REBOL 2 programming languages.

For the REBOL family of languages, 0MQ is an alternative to the native REBOL/Services system. REBOL/Services is only available for REBOL 2, while these bindings enable communication between Red, REBOL 3 and REBOL 2. Further, 0MQ enables cooperation with programs written in other languages that have a 0MQ interface available. Note that the two systems have a different bias. REBOL/Services defines the format of messages, while 0MQ does not. It would be possible to implement REBOL/Services on top of 0MQ, using 0MQ as the (advanced) transport layer.

Please note that these projects are in an early stage. The bindings do not support all functionality of 0MQ yet and haven't seen much testing, so you should do your own testing to make sure they are reliable for your purposes.

The binding for REBOL 3 comes in the form of a REBOL 3 extension. This documentation assumes that you are familiar with the basics of REBOL 3 extensions. Please refer to this introduction document for more information.

Licence

The source code of the bindings and the binary versions on this page are licensed to you under a BSD open source licence:

    - Red binding
    - REBOL 3 binding
    - REBOL 2 binding

This licence does not apply to other parts, such as this documentation, for which all rights are reserved, and the 0MQ library, which is under the LGPL licence.

Reporting Issues

The source code of the Red and REBOL 2 bindings and the program examples is kept in Fossil repositories:

    - Red binding
    - REBOL 2 binding

You can explore the source code there and use the ticket system of each repository to report issues.

See the home page for other methods to contact us and discuss about all bindings, including the REBOL 3 binding.
programming language]

How to Install REBOL 3

Before you can use the extension, you need REBOL 3 on your computer. See here for instructions on downloading and installing it.

Installing the 0MQ Library

0MQ is available for multiple operating systems. You will need to find a binary installation package for your system and follow the appropriate installation instructions. If your system has a central software management facility or packages listing, you should try that first.

Installing the Binding

Don't be alarmed by the small size of the downloads. They're much smaller than this web page. :-)

The source code versions of the bindings are configured for a version of 0MQ of at least 2.0.7.

The Red/System binding currently only works on Windows, because Red can't load libraries on other systems yet. It must be compiled from the source code by including it in a program.

The REBOL 2 binding can be loaded from the source code as-is on Linux, Mac and Windows. For other systems, the path to the C library may have to be adjusted:

    ZeroMQ-binding.r2

Here's our main binary version of the REBOL 3 extension, for Syllable and Linux systems:

    ZeroMQ-binding.so

This version was compiled on Syllable Server 0.4. It should also be usable on most other Linux systems for IA-32 (486 compatible) processors. It should be usable on 64 bits systems if they have 32 bits compatibility support installed.

This extension needs a version of 0MQ not higher than 2.0.6. This is the version available for Ubuntu Linux 10.10 systems and derivatives.

If you have a different system or 0MQ version, and both REBOL 3 and 0MQ are available for your system, you will have to compile the binding from its source code, as described further on.

The extension doesn't need to be unpacked and doesn't necessarily need to be installed. It's a single file that is a dynamic (shared) library. It can be loaded into REBOL from any place. If you want to refer to it without explicitly specifying the path, the file needs to be installed in a standard library location, where the operating system can find it. Refer to instructions for your system on how to do that.
[Syllable operating system family]

How to Install the Binding on Syllable

On Syllable Server, if you want to install the REBOL 3 binding in the system for future use, the easiest way to do that is by moving the ZeroMQ-binding.so file to the /system/libraries/ directory.

How to Install the Binding on Windows

The REBOL 3 extension must be compiled on Windows from the source code.

The REBOL 2 binding can be loaded from the source code as-is.

The Red binding must be compiled from the source code by including it in a program. Two demo programs are available that show a basic client/server request/reply example, where the client program sends ten “Hello” messages over a local loopback network connection and the server responds with a “World” message:

    reply-server.exe (3 KB)
    request-client.exe (3 KB)

In the likely case that you don't have 0MQ installed yet, the libzmq.dll library can be extracted from the external package here:

    0MQ library

The easiest way to use it is to simply put the library file in the same folder as the programs. You may also need to install an MSVC Redistributable Package if it isn't installed on your computer yet. At the time of writing, the 2008 version was needed (but a newer version may be more appropriate):

    MSVC Redistributable Package 2008 SP1

Using the Binding

For information about the meaning of the library interface, please refer to the 0MQ documentation and the following examples. More examples will be added here over time.

Request/Reply Client/Server

This request/reply example has a server program that keeps running, waiting for requests. The client program sends ten messages over a local loopback network connection with the content “Hello”. The server replies each message with a “World” message.

Here is the example code for Red/System:

    reply-server.reds
    request-client.reds

For REBOL 3:

    reply-server.r3
    request-client.r3

For REBOL 2:

    reply-server.r2
    request-client.r2

Source Code

The source code of the Red and REBOL 2 bindings and the program examples is kept in Fossil repositories:

    - http://red.esperconsultancy.nl/Red-ZeroMQ-binding
    - http://rebol.esperconsultancy.nl/REBOL-2-ZeroMQ-binding

You can use these links in Fossil commands, or you can use them in a web browser to explore the source code and report issues.

Archives of the latest versions can be downloaded here:

    - Red-ZeroMQ-binding.zip
    - REBOL-2-ZeroMQ-binding.zip

The source code of the REBOL 3 binding is kept in the build system of the Syllable operating systems, but it's not hard to use it on other systems:

    - REBOL 3 binding
version control system]

How to Use Fossil

Fossil is a modern, distributed version control system, that you can use to access the source code of these projects and keep it up-to-date. See here for instructions on installing and using Fossil.

Compiling the Binding

REBOL 3 is available for several computer platforms. In principle, the REBOL 3 binding can be compiled on all of them. No changes to the binding itself should be necessary, but the build environment needs to be set up and the build configuration may need some changes. This is all standard procedure for compiling C programs, so you will need to follow the procedures for your system. The configuration of the extension is made with POSIX systems in mind. If you want to compile it on Windows, it is easiest to do that in the MinGW build environment.

The binding needs the REBOL 3 open host environment as a base to compile on, so you need to download that, as well. The source code of the open host kit is hosted in a Git repository.

You can either put the files of the binding in the root directory of the host kit, or if you put them in a separate work directory, you will have to adjust the makefile of the extension to point to the REBOL host environment. The makefile is also where you may have to make other changes for your environment. It is preconfigured for Linux and Syllable systems. There are hints in there for compiling on Windows in the MinGW environment.

When the makefile is configured, doing the compilation is standard procedure. In most cases, all that is needed is the following command, given in a terminal in the same directory as the makefile and the binding source files:
make
The result should be an extra binary file called ZeroMQ-binding.so (it may have a different file extension on your system). If this failed, error messages will have been printed that you can use to sort out the problem.
[Syllable operating system family]

How to Compile the Binding on Syllable Server

The REBOL 3 binding can be compiled on Syllable Server by following the general procedure, described above. However, it's much easier to let the Syllable build system do all the work of downloading both the binding and the REBOL host kit, installing them and then compiling the extension. In any case, you need to have the following software packs installed:

    - Development files pack for your exact Syllable version
    - Developer's Delight
    - Network Necessities

Then enter the following commands:
s build update
build log
build ZeroMQ-Binding--current
build log
The resulting binary file ZeroMQ-binding.so will be in the directory ZeroMQ-Binding--current.


Powered by * Syllable Server
Published by Esper consultancy 2011-2012
All Rights Reserved