ZeroMQ wrapper for D2

Kean Forrest keanf at gmail.com
Sun Oct 23 05:25:32 PDT 2011


On 22/10/11 23:24, simendsjo wrote:
> I saw someone mention ZeroMQ in a subthread the other day. I watched a
> few videos, and it looks to me like a good fit for D. The philosophies
> matches pretty well: small, clean api, no bloat (only transport, no
> protocols), very flexible setup/usage and message passing for
> communication.

+1

ZMQ seems almost too good, I never knew it existed. If D had this as a 
networking/concurrency method it would be a huge plus AFAIK.

This wrapper (2.1.10 stable) is closer to the python version:

http://min.us/lOZ88QxPWyB6q

Hello world:

import zmq.zmq;
import std.stdio;
void main()
{
     auto ctx = new Context();
     version(client)
     {
         auto sock = ctx.socket(ZMQ_REQ);
         sock.connect("tcp://localhost:5555");
         sock.send("hello");
         writeln(sock.recv!string);
     }
     else
     {
         auto sock = ctx.socket(ZMQ_REP);
         sock.bind("tcp://*:5555");
         writeln(sock.recv!string);
         sock.send("world");
     }
}


More information about the Digitalmars-d-learn mailing list