[zeromq-dev] Newbie question

Howard howard at renci.org
Fri Oct 11 20:53:07 CEST 2013

Hi all

I hope you will forgive a newbie question. Please feel free to send me 
to a different resource if this question is in the wrong forum.

I've been teaching myself zeromq in combination with protobuffers. I've 
been using the request/reply sockets and it's working perfectly in my 
simple test codes. But now I need a slightly more complicated pattern 
and I'm not quite sure how to do it. Here is my situation:

On one side I have a short lived client program with I would like to 
connect to a server.  Because there can be a few of these simultaneously 
I would like my server to be multi-threaded.  The situation is similar 
to Figure 20 in http://zguide.zeromq.org/page:all.  So far so good.  The 
issue however, is that I want each of my clients to interact with the 
same server thread over the life of it's invocation.  This is because 
the threads of the server are interacting with a stateful resource and 
multiple transactions between client and server are required to complete 
an operation. From what I understand of zeromq, it seems to me that I 
want either to

 1. Have the dealer make sure it forwards each request from a particular
    client to the same worker thread.  Is there a recommended technique
    for this?
 2. Have each client socket connect directly to a socket in the worker
    thread using some pattern that I don't see in the documentation. It
    seems possible to me that this idea is antithetical to the zeromq
    paradigm, so I wonder if I have some fundamental misunderstanding of
    zeromq or if I just missed something or maybe both.  Well, I did say
    I was a newbie. :)
 3. Rethink the idea that each client should only communication with the
    same thread.  I'm not sure if this is a possibility, but if 1 and 2
    are difficult, I may want to investigate this further. At the least,
    I need each worker thread to understand which client thread it is
    communicating with.  I suppose I could put some type of session key
    in the message protocol if I knew how to get this info from zeromq.

Any comments or suggestions (even RTFM with a pointer to the correct 
section) would be greatly appreciated.


Howard Lander <mailto:howard at renci.org>
Senior Research Software Developer
Renaissance Computing Institute (RENCI) <http://www.renci.org>
The University of North Carolina at Chapel Hill
Duke University
North Carolina State University
100 Europa Drive
Suite 540
Chapel Hill, NC 27517
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20131011/57a8cb49/attachment.htm>

More information about the zeromq-dev mailing list