title: ZeroMQ C++ epgm pub-sub not working
body: <p>Here is my code of publisher and subscriber using epgm in zeroMQ, where publisher publishes a string "x." continuously and subscriber should receive the messages but it is not happening in this code. </p>
  
  <p>** publisher code:**</p>
  
  <pre><code>include zmq.hpp 
  include string 
  include unistd.h 
  include iostream 
  using namespace std;
  
  
  int main(int argc, char *argv[])
  {
  
      void *context = zmq_init(1);
  
      void *publisher = zmq_socket(context, ZMQ_PUB);
  
      zmq_bind(publisher, "epgm://eth0;239.192.1.1:5555");
  
  
      string s = "x.";
  
  
      while (1)
      {
  
      zmq_msg_t message;
  
      zmq_msg_init_size(&amp;message, s.size());
  
      memcpy(zmq_msg_data(&amp;message), s.c_str(), s.size());
  
  
      int rc = zmq_sendmsg(publisher, &amp;message, ZMQ_DONTWAIT);
  
      }
  
      sleep(3);
  
  }
  </code></pre>
  
  <p><strong>Subscriber code:</strong></p>
  
  <pre><code>include zmq.hpp 
  include string 
  include unistd.h 
  include iostream 
  using namespace std;
  
  int main(int argc, char *argv[])
  {
  
      zmq::context_t context(1);
  
      zmq::socket_t subscriber(context, ZMQ_SUB);
  
      string subscription = "x";
  
      zmq_connect(subscriber, "epgm://eth0;239.192.1.1:5555");
  
      const char *filter = (argc &gt; 1) ? argv[1] : "x";
  
      subscriber.setsockopt(ZMQ_SUBSCRIBE, filter, strlen(filter));
  
      int ret_val;
  
      while (1)
      {
  
      string msg_buffer;
  
      zmq_msg_t message;
  
      zmq_msg_init(&amp;message);
  
      if ((ret_val = zmq_recvmsg(subscriber, &amp;message, ZMQ_DONTWAIT)) &lt; 0)
      {
  
          cout &lt; "Not receiving";
  
          cout ret_val;
  
          sleep(1);
  
          continue;
  
  
      }
  
      int size = zmq_msg_size(&amp;message);
  
      msg_buffer.assign((const char *) zmq_msg_data(&amp;message), size);
  
      cout &lt;&lt; "Msg buffer : " &lt;&lt; msg_buffer &lt;&lt; endl;
  
      }
      sleep(3);
  
  }
  </code></pre>
  
  <p><strong>Output:</strong> </p>
  
  <pre><code>    Not receiving
      -1
  
      Not receiving
      -1
  
      Not receiving
      -1
  
      Not receiving
      -1
  
      Not receiving
      -1
  
      Not receiving
      -1
      Not receiving
      .
      .
      .
  </code></pre>
  
  <p>Please suggest me why is this happening so...and how to solve this ?</p>