[zeromq-dev] Implicit multithreading woes.

Claudio Carbone erupter at libero.it
Sat Dec 22 15:13:10 CET 2012

Code of my classes attached.
A main would look like this

int main (void)
     Zmqcpp::Context mycontext(1);
     Zmqcpp::Publisher mypubber(mycontext, "tcp://*:5678", ZMQCPP_BIND);
     Zmqcpp::Subscriber mysubber(mycontext, "tcp://localhost:5678", 


         char mystr[3];
         mypubber.PubMessage(3,"A","We don't want to see this",mystr);
         mypubber.PubMessage(3,"B","We would like to see this",mystr);
         printf("Cycle [%s]\n",mystr);
         for (int i=0;i<3;i++)
             cout << mysubber.receive() << std::endl;


     return (EXIT_SUCCESS);


On 12/22/2012 02:14 PM, Claudio Carbone wrote:
> To make debugging an application easier I often joined the server and 
> client in a single program.
> Now I'm using my own c++ classes built on top of the c bindings.
> This means I have a class instance for every object:
> Context,socket,publisher and subscriber.
> When used like this I find that somehow multiple threads are spawned 
> automatically effectively nullifying having both sides in a single 
> application.
> In fact unless I start putting in callbacks,output redirection and 
> other stuff, having multiple threads makes my life a lot harder:gdb 
> starts having problems following the code (sometimes problems seem to 
> happen nowhere or just in disassembly), simple stdout doesn't work, 
> and so on.
> Now unless I forgot something (quite plausible) ZMQ should create 
> threads just on context creation.
> Why am I seeing multiple threads with a single context?
> Being on the phone I don't have the code, will post it later.
> Thank you
> Claudio
> -- Sent from my ParanoidAndroid Galaxy Nexus with K-9 Mail.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: zmqcpp.cpp
Type: text/x-c++src
Size: 8894 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20121222/e11c5e43/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zmqcpp.h
Type: text/x-chdr
Size: 3507 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20121222/e11c5e43/attachment.h>

More information about the zeromq-dev mailing list