title: ZeroMQ mixed PUB/SUB DEALER/ROUTER pattern
body: <p>I need to do the following:</p>
  
  <ul>
  <li>multiple clients connecting to the SAME remote port</li>
  <li>each of the clients open 2 different sockets, one is a <strong><code>PUB/SUB</code></strong>, the
  other is a <strong><code>ROUTER/DEALER</code></strong> ( the server can occasionally send back to client heartbeats, different server related information ).</li>
  </ul>
  
  <p>I am completely lost whether it can be done in ZeroMQ or not.
  Obviously if I can use 2 remote ports, that is not an issue, but I fail
  to understand if my setup can be achieved with some kind of envelope
  usage in ZeroMQ.
  Can it be done?
  Thanks,</p>
  
  <p><strong>Update</strong>:</p>
  
  <p>To clarify what I wish to achieve.  </p>
  
  <ul>
  <li>Multiple clients can communicate with the server  </li>
  <li>Clients operate on request-response basis mostly(on one socket)  </li>
  <li>Clients create a session socket, which means that whenever this<br>
  type of socket is created, a separate worker thread needs to be created
  and from that time on the client communicates with this worker thread
  with regards to requests processing, e.g. server thread must not block
  the connection of other clients when dealing with the request of one client  </li>
  <li>However clients can receive occasional messages from the worker thread with regards to heartbeats of the worker.  </li>
  </ul>
  
  <p><strong>Update2</strong>:</p>
  
  <p>Actually I could sort it out. What I did:  </p>
  
  <ul>
  <li>identify clients obviously, so <code>ROUTER/DEALER</code> is used, e.g. clients
  are indeed dealers, hence async processing is provided  </li>
  <li>clients send messages to the one and only local port, where the router sits  </li>
  <li>router peeks into messages (kinda the lazy pirate example), checks whether a new client comes in; if yes it offloads to a separate thread, and connects the separate thread with an internal "<strong><code>inproc:</code></strong>" socket</li>
  <li>router obviously polls for the frontend and all connected clients' backends and sends messages back and forth.</li>
  </ul>
  
  <p>What bugs me is that it is an overkill if I compare this with a "regular" socket solution, where I could have connected the client with the worker thread DIRECTLY (e.g. worker thread could recv from the socket opened by the client directly), hence I could spare the routing completely.<br>
  <strong>What am I missing?</strong></p>