I installed 2.1 and things look better. Instead of using zmq_poll on two socket, I will try to subscribe to the inproc and manually detect "connect" messages.
Thanks for the feedback. Gaspard On Sun, Jan 2, 2011 at 12:42 PM, Martin Sustrik <[email protected]> wrote: > Hi Gaspard, > > > I have a zmq.SUB socket handling remote messages in thread A. It spends >> most of its time in recv(). >> >> Some other thread B running mDNS finds services and I want it to connect >> the subscriber (created in thread A) to the remote end. >> >> Is it ok to connect from a different thread ? >> > > No. You cannot access one socket from multiple threads. In 2.1 you can > migrate a socket to another thread, however, you still can't access it from > multiple threads in parallel. > > >> Is it ok to connect while the socket is in recv() ? >> > > No. As explained above, a socket is not thread-safe. > > > If not, one solution I see would be to connect the subscriber to an ipc >> socket (created in the mDNS loop) to receive connection info. Is this >> the way to handle such a pattern ? >> > > Yes. You can create another socket to pass connection info's to the > subscriber thread. The subscriber thread then has to wait using zmq_poll, > polling on both sockets, instead of simply calling recv. > > HTH > Martin >
_______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
