[zeromq-dev] Windows and PGM

Martin Sustrik sustrik at 250bpm.com
Fri Mar 26 07:05:27 CET 2010

gonzalo diethelm wrote:

> I am doing something similar in my own system. I think it all boils down
> to defining "connections" (for lack of a better term), which are a
> combination of:
> * Name: unique identity
> * Endpoint: inproc://pipe, tcp://, etc.
> * Type: PUB, SUB, REQ, REP, etc.
> * Action: bind, connect
> If you could pass a list of these to your class, then you would simply
> create all these "connections" and then have a poll loop in your own
> thread. 

What I am trying to avoid is to pass large number of parameters to the 
API. In addition to the above, socket options should be passed etc. What 
if you just passed fully established sockets to the API?

void *zmq_device (int type, void *in_socket, void *out_socket);
int zmq_device_close (void *device);

> So for a streamer you could have:
>   ear = <tcp://; REP; bind>
>   mouth = <tcp://; REQ; connect>
> Then your class would know it has to create "ear" and "mouth" and then
> start polling.
> This could apply to any kind of "device"; a node in my topology might
> need a SUB socket, a REQ socket and an UPSTREAM socket, which I would
> define this way as well.

So what you'll have would look something like this:

void *ear = zmq_socket (ctx, ZMQ_SUB);
zmq_bind (ear, "tcp://");
zmq_setsockopt (ear, ZMQ_SUBSCRIBE, "forex.", 6);
void *mouth = zmq_socket (ctx, ZMQ_PUB);
zmq_connect (ear, "tcp://");
zmq_device (ZMQ_FORWARDER, ear, mouth);


More information about the zeromq-dev mailing list