[nanomsg] Req/Rep setup...

  • From: Soren Riise <sorenriise@xxxxxxxxxxx>
  • To: Nanomsg <nanomsg@xxxxxxxxxxxxx>
  • Date: Wed, 20 Aug 2014 19:08:17 +0100

I was wondering how the Rep/Req setup would work with a server and multiple 
clients making requests, as there is nothing in the API which signals which 
client the server is replying to when it get a request.    However it looks 
like the API is keeping some internal state which make it kind of work.

When Im saying kind of work, I mean it works as long as Im not trying to do 
anything fancy on the server side.    However if the server implement an event 
loop (or is MT) and the reply becomes a deferred operation resolved later, then 
there is no way of directing the reply back to the original client.

c1      c2      server
req1 ------------>defer -+
        req2-----> +     |
        res2<----- +     V
                  req1 ready
 <- - - - ?-- res1 +


What I see is that the res1 actually goes to c2 instead of c1 which is probably 
caused by an internal global state of the connection set to be the last active 
connection.

Is there an API for getting and setting the state of the connection on the 
server side so that the server can programmaticly solve this -- or is there are 
better solution for this?

This is particularly a really bad problem for non-blocking programming which is 
common these days such as in nodejs.

Other related posts: