title: zeroMQ: zmq_recv() doesn't work
body: <p>I am using zeroMQ to realize the send-recv message. I use this pattern: PUB-SUB.<br>However, it seems that I can send some message from the publisher but I couldn't receive it from the subscriber. Here is my code:<br></p>
  
  <p>//subscriber:</p>
  
  <pre><code>int main(int argc, char** argv){
      void * context = zmq_ctx_new();
      void * subscriber = zmq_socket(context, ZMQ_SUB);
      zmq_connect(subscriber, "tcp:://127.0.0.1:5556");
      const int SIZE = 20;
      char msg[SIZE];
      cout&lt;&lt;"receiving..."&lt;&lt;endl;
      cout&lt;&lt;zmq_recv(subscriber, msg, SIZE, 0)&lt;&lt;endl;
      cout&lt;&lt;"received";
      zmq_close(subscriber);
      zmq_ctx_destroy(context);
      return 0;
  }
  </code></pre>
  
  <p>//publisher:</p>
  
  <pre><code>int main(int argc, char** argv){
      void * context = zmq_ctx_new();
      void * publisher = zmq_socket(context, ZMQ_PUB);
      zmq_bind(publisher, "tcp://127.0.0.1:5556");
      srandom((unsigned)time(NULL));
      char updateMsg[20] = "hello world";
      while(1)
      {
          cin.get();
          cout&lt;&lt;"sending..."&lt;&lt;endl;
          cout&lt;&lt;zmq_send(publisher, updateMsg, 20, 0)&lt;&lt;endl;
          cout&lt;&lt;"sent"&lt;&lt;endl;
      }
      zmq_close(publisher);
      zmq_ctx_destroy(context);
      return 0;
  }
  </code></pre>
  
  <p>Now, I run the publisher then I run the subscriber.<br>
  Then I type "Enter" at the publisher and it says:</p>
  
  <pre><code>sending...
  20
  sent&lt;l
  </code></pre>
  
  <p>BUT, at the subscriber, it always shows only this line: <code>receiving...</code><br>
  It seems that <code>zmq_recv()</code> is blocked.</p>
  
  <p>Could you please help me?</p>