[zeromq-dev] C++ high level binding

Ilja Golshtein ilejncs at narod.ru
Thu Nov 3 15:17:39 CET 2011

03.11.2011, 17:36, "Pieter Hintjens" <ph at imatix.com>:
> On Thu, Nov 3, 2011 at 2:27 PM, Ilja Golshtein <ilejncs at narod.ru> wrote:
>>  C++ simplifies resource management so maintaining socket lifetime is not as painful as in pure C.
> The problem is not C/C++ but that zmq_term requires that you
> explicitly set LINGER on any active sockets, and close all sockets,
> before calling zmq_term, otherwise applications block forever at
> shutdown.

You are right of course, but things like objects and like smart pointers 
make housekeeping in C++ world much more simple.

>>  I am not a big fan of Swiss knife alike tools and don't understand why messaging library should control user threads,
>>  why GUI library should operate with DB, etc.
> There are three reasons:
> * to enable portable code, since threading is different on POSIX and Windows
> * to properly track socket creation, so shutdown can work safely
> * to provide higher-level semantics for threads, e.g. attached
> (sharing same context, connected by inproc 'pipe') / detached (using
> their own context) threads in CZMQ

All these reasons make sense of course and it is clear CZMQ is great.

My personal background  is slightly different. 

I don't care about crossplatforming.
I do care about large applications use many libraries (even for communication purposes) and have
to combine these libraries with each other. 
Such applications usually have solutions for generic things like threads and it is difficult 
or impossible to create threads via a messaging library API call.
And I do care about performance. 

That's why zmqmessage library is not a С++ equivalent for CZMQ.

>>  Reactors are different.
> Also useful, because they simplify many more complex 0MQ patterns.

We have a C++ reactor library for 0mq.
In principle it is possible to make it open source and to make it standalone, but there are some complexities. 
For example, it uses special way to create threads ...

Not sure I've convinced you that zmqmessage is a right thing for C++,  
but I hope that I managed to give some reasons behind this design.

Best regards,
Ilja Golshtein.

More information about the zeromq-dev mailing list