[nanomsg] Re: A multiple client/worker for NN_PAIR style sockets.

  • From: Alex Elsayed <eternaleye@xxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Wed, 07 Jan 2015 14:28:45 -0800

Honestly, this sounds like a misdesign - the semantics you want are TCP 
semantics, and you'd basically only be using nanomsg as framing.

People use ZMQ that way, but it was explicitly left out of the intended 
usecases of nanomsg if I remember correctly.

It may be best to decompose your protocol into multiple parts. Could you 
give more information on what _actually_ gets sent back and forth? I'd be 
willing to help.

Nanomsg is designed around "patterns" - higher-level communication 
primitives - _instead_ of application-level free messages.

Here are some that might be useful for your case:
Messages that need a response, but only from one peer: REQ/REP
Messages that need a response from the set of peers: SURVEY
One-way messages to all: PUB/SUB
One-way messages to one peer: PUSH/PULL

Also, them being on different networks isn't _that_ tricky - you can use 
nn_device to create a sort of bridging point.


> Hi all,
> 
> I need to create a system where there are several clients that can
> communicate simultaneously with a server. For simplicity, we can assume
> that the server has a constant number of workers.
> 
> The clients can send messages to the servers and the workers may respond
> to these messages and/or send messages by itself possibly expecting
> responses. In other words, there's free two way communication between a
> client and the server.
> 
> Using NN_PAIR with devices results in the error "transport endpoint
> already connected" when the second worker tries to connect to the local
> "inproc" socket. Using a solution that creates a pair of NN_PUSH/NN_PULL
> sockets also won't work because the client and server are on different
> networks and providing a connection endpoint on the client for the server
> to connect to will be tricky.
> 
> Is there a way in nanomsg to have free two-way communication between
> multiple clients and a single server?
> 
> Thanks,
> Rohit



Other related posts: