[zeromq-dev] REQ / REP and inproc sockets
gdiethelm at dcv.cl
Wed Aug 25 18:11:46 CEST 2010
If this is a known issue, I apologize for not paying attention.
I am developing a small client/server app in Java and 0MQ. The client
does the following:
* On the main thread:
+ Create a REQ socket bound to inproc://r
+ Add that socket to a Poller.
+ Spawn a new thread.
* On the new thread:
+ Create a REP socket connected to inproc://r and a REQ socket connected
to tcp://127.0.0.1:5555, where my server has a REP socket bound.
+ Loop: read from inproc://r and write to tcp; read from tcp and write
to inproc://r. Notice the new thread does not poll, it simply issues
blocking recv and send calls.
* Back on the main thread:
+ Send one request down inproc://r.
+ Poll for incoming messages (only on inproc://r).
+ The expectation is that the main thread will wake up from the poll and
will be able to process the response it got from the remote server.
This whole thing works, but NOT most of the time. Sometimes the new
thread writes the reply on inproc://r but the main thread never wakes up
from the poll. Or, the main thread writes the message on inproc://r but
the new thread never receives it. The only common factor between the two
errors is the use of an inproc socket between the two threads. I have
taken care to create each socket within its proper thread.
The fact that it DOES work sometimes is the most tantalizing. I thought
I would run this design by the list to check for any more-than-usual
stupidity on my part, before I dive into the debugging process. Could
this be related to the use of REQ/REP sockets and their strict ordering
Thanks for any hints and best regards.
More information about the zeromq-dev