hxzmq: ZeroMQ binding for Haxe

You are viewing an old version of this entry, click here to see latest version.

Welcome to hxzmq, Haxe language bindings for the ZeroMQ messaging library. It is written and maintained by Richard Smith of RSBA Technology Ltd

ZeroMQ (shortened to “0MQ”) is a lightweight, fast messaging C library that implements several different message topologies across different transports, both with brokers or “brokerless” designs, or any interesting combination of the two. It has community – provided bindings for over 15 application languages (including Haxe!) and has been compiled to run on Windows, Linux, iOS and Mac0SX operating systems, amongst others. 0MQ is maintained as an open source project by iMatix Corporation and a strong development community, and is licensed under LGPL.

A Quick Example

This shows a simple filter device that collects data from two different remote publishers and sends it local subscribers:
package ;
import haxe.io.Bytes;
import org.zeromq.ZContext;
import org.zeromq.ZMQ;
import org.zeromq.ZMsg;

class Example 
    public static function main() {
        var context = new ZContext();
        var subscriber = context.createSocket(ZMQ_SUB);
        subscriber.setsockopt(ZMQ_SUBSCRIBE, Bytes.ofString("NASDAQ"));
        var publisher = context.createSocket(ZMQ_PUB);
        while (true) {
            var message = ZMsg.recvMsg(subscriber);

Ensure that libzmq is installed on your development machine (see: http://www.zeromq.org/intro:get-the-software)

If you want to use the php target, you must also install the php-zmq 0MQ binding (see http://www.zeromq.org/bindings:php)

Then install hxzmq from haxelib (or install from source):

haxelib install hxzmq

Compile & run for your chosen target platform, eg:

(For cpp on Mac0SX or Linux):

haxe –lib hxzmq -D HXCPP_M64 –cpp out/Mac64 –cp . –main Example
cd out/Mac64

(For neko on Windows):

haxe –lib hxzmq –neko out/Windows/main.n –cp . –main Example
cd out/Windows
neko main.n

(for php on any platform, running using PHP CLI):

haxe –lib hxzmq –php out –cp . –main Example
cd out
php –f index.php

version #10754, modified 2011-07-19 12:42:56 by rjsmith