[zeromq-dev] equivalent of accept
B.Candler at pobox.com
Wed Apr 21 10:28:36 CEST 2010
On Wed, Apr 21, 2010 at 08:25:51AM +0800, Steven McCoy wrote:
> Could you also clarify for my benefit: if you have (say) five worker
> which want to handle incoming REQs from clients, should the five
> threads all
> call zmq_recv on the same socket, or should the five threads each
> their own zmq_socket bound to the same proto/port?
> From my understanding it is each thread must have it's own ZMQ socket,
> there is no thread safety for the sake of performance. Therefore the
> second option would have to be the only viable route.
>> require 'zmq'
>> ctx = ZMQ::Context.new(2,2,0)
>> s1 = ctx.socket(ZMQ::REP)
>> s2 = ctx.socket(ZMQ::REP)
RuntimeError: Address already in use
from (irb):7:in `bind'
Since REP/REQ is lock-step, if you want concurrency you need multiple worker
threads. And since you can't bind multiple sockets to the same IP+port,
they'd have to share the same socket.
More information about the zeromq-dev