[nanomsg] ZMQ_ROUTER like functionality

  • From: David Robillard <d@xxxxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Wed, 17 Sep 2014 12:42:38 -0400

Hello,

I'm looking for port an application from zeromq to nanomsg.  Most of the
missing/different functionality I can figure out how to implement, but
one thing isn't clear:

How can I get ZMQ_ROUTER like functionality with nanomsg?  Specifically,
I need to explicitly send messages to a specific connection of the
socket.  The docs say "use L4 protocols" for that, but I'm not sure what
solution this is suggesting (there is an old thread about this, but no
solutions there either).

My architecture is a (multi-threaded) server which needs to route
requests to specific workers, because workers host different sets of
data (so workers are not interchangeable).  These requests are
synchronous REQ/REP.

I could do this by adding the address as a header to my payload, and
implementing a router myself, but this would require a separate socket
for each worker.  This seems less than ideal since there are many server
threads and workers, so this would be a lot of sockets and connections
(each server thread would need a socket for each worker).  Since nanomsg
supports many connections per socket, it seems strange to have to do
this.

Is there, or could there be, an option in the auxiliary data to specify
which connection to route the message to, or some other better solution?

Another, perhaps related, issue, is that I need an asynchronous
REQ/REP-like connection between clients and the server, for high
throughput.

It seems that raw nanomsg sockets make it possible to do such things,
but how to go about it isn't clear to me.

Thanks,

-- 
dr


Other related posts: