<p dir="ltr">I think you have to set socket options before connecting instead of after.</p>
<div class="gmail_quote">On Nov 9, 2013 7:30 PM, "Gerhard Martin" <<a href="mailto:galeomaga@gmail.com">galeomaga@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">why not receive message in subscriber<br><br>void task2(int testparam)<br>{<br>    printf("task 2 %d\n", testparam); <br>    <br>    zmq::context_t context(1);  <br>    zmq::socket_t subscriber(context, ZMQ_SUB); <br>
    printf("before connect\n"); <br>    subscriber.connect("tcp://<a href="http://127.0.0.1:5556" target="_blank">127.0.0.1:5556</a>");  <br>    printf("after connect\n"); <br>    const char *filter = "";  <br>
    subscriber.setsockopt(ZMQ_SUBSCRIBE, filter, strlen(filter));  <br>    zmq::message_t update;  <br>    //subscriber.recv(&update); <br>    //printf("end recv %s", update.data());<br>    while(true){ <br>
        //try<br>        //{    <br>            printf("server begin recv\n");<br>            subscriber.recv(&update); <br>            printf("succeed to receive\n");<br>            printf("server end recv %s\n", static_cast<char*>(update.data()));<br>
            //printf("%s is sent\n", (void *)reply.data());<br>        //}catch(...)<br>        //{<br>            //printf("Sub Receiver Error ");<br>        //}<br>    }<br>}<br><br>main(){<br>...<br>
zmq::context_t context(1);  <br>    zmq::socket_t publisher (context, ZMQ_PUB);  <br>    printf("before bind\n");<br>    publisher.bind("tcp://*:5556");  <br>    printf("after bind\n");<br>    zmq::message_t reply(12);<br>
    memcpy ((void *) reply.data(), "Martin", 6);<br>    printf("%s is sent\n", (void *)reply.data());<br>    printf("before send\n");<br>    for(int k=0; k<10; ++k)<br>    {<br>        publisher.send(reply); <br>
    }<br></div><br>_______________________________________________<br>
zeromq-dev mailing list<br>
<a href="mailto:zeromq-dev@lists.zeromq.org">zeromq-dev@lists.zeromq.org</a><br>
<a href="http://lists.zeromq.org/mailman/listinfo/zeromq-dev" target="_blank">http://lists.zeromq.org/mailman/listinfo/zeromq-dev</a><br>
<br></blockquote></div>