title: ZeroMQ Poll - Resource temporarily unavailable
body: <p>I am trying to run a small ZeroMQ application.<br>
  <strong>I am working on an Ubuntu machine</strong> with also a QT framework used in my code.<br>
  First of all, I create a <code>test_class</code>. This class creates a socket and a context, than establishes a connection.<br>
  Here is my test class :</p>
  
  <p><strong>Header File :</strong> </p>
  
  <pre><code>class test_class
  {
  public:
      test_class();
      ~test_class();
  
      zmq::socket_t* get_conn_socket() const;
      void establish_connection();
  
  private:
      zmq::context_t * m_context;
      zmq::socket_t * m_socket;
  };
  </code></pre>
  
  <p><strong>Source File :</strong></p>
  
  <pre><code>#include "test_class.h"
  
  test_class::test_class()
  {
      m_context = new zmq::context_t(1);
      m_socket = new zmq::socket_t(*m_context, ZMQ_DEALER);
  }
  
  test_class::~test_class()
  {
  
  }
  
  zmq::socket_t* test_class::get_conn_socket() const
  {
      return m_socket;
  }
  
  void test_class::establish_connection()
  {
      m_socket-&gt;connect("tcp://localhost:9999");
  }
  </code></pre>
  
  <p>In the main code, I create a <code>test_class</code> instance and establish a connection, using this instance. Then wait for some message from the broker.</p>
  
  <pre><code>qDebug() &lt;&lt; "TEST CODE WORKING";
  
  int mtime = 1000;
  test_class *test = new test_class();
  test-&gt;establish_connection();
  
  s_send(*(test-&gt;get_conn_socket()), "READY");
  
  while(true)
  {
      zmq::socket_t* temp_socket = test-&gt;get_conn_socket();
      zmq::pollitem_t items[] = { { *temp_socket, 0, ZMQ_POLLIN, 0} };
      if( zmq_poll(items, 1, mtime) &gt; 0)
      {
  
          qDebug() &lt;&lt; "ZMQ_POLL_IN";
  
          if ( items[0].revents &amp; ZMQ_POLLIN )
          {
              zmsg msg(*temp_socket);
  
              if(strcmp(msg.body(), "HEARTBEAT") == 0)
              {
                  qDebug() &lt;&lt; "HEARTBEAT message";
              }
              else
              {
                  qDebug() &lt;&lt; "SOME OTHER message";
              }
          }
      }
      else
      {
          qDebug() &lt;&lt; zmq_strerror(errno);
      }
  
  
      s_send(*temp_socket, "HEARTBEAT");
  
  }
  </code></pre>
  
  <p>Finally,<br>
  my <code>test_class</code> output is like this : </p>
  
  <pre><code>Resource temporarily unavailable 
  Resource temporarily unavailable 
  Resource temporarily unavailable 
  Resource temporarily unavailable 
  Resource temporarily unavailable 
  Resource temporarily unavailable 
  Resource temporarily unavailable 
  Resource temporarily unavailable 
  Resource temporarily unavailable 
  </code></pre>
  
  <p>And <code>broker_code</code> output is:</p>
  
  <pre><code>HEARTBEAT MESSAGE COME FROM WORKER
  HEARTBEAT MESSAGE COME FROM WORKER
  HEARTBEAT MESSAGE COME FROM WORKER
  HEARTBEAT MESSAGE COME FROM WORKER
  HEARTBEAT MESSAGE COME FROM WORKER
  HEARTBEAT MESSAGE COME FROM WORKER
  HEARTBEAT MESSAGE COME FROM WORKER
  </code></pre>
  
  <p>When I check the communication between the broker code and my code, using a tcpdump, the tcpdump's output is like this :</p>
  
  <pre><code>19:58:37.815283 IP localhost.9999 &gt; localhost.39278: Flags [.], ack 33, win 342, options [nop,nop,TS val 3575439312 ecr 3575439312], length 0
  19:58:38.816456 IP localhost.39278 &gt; localhost.9999: Flags [P.], seq 33:44, ack 1, win 342, options [nop,nop,TS val 3575440313 ecr 3575439312], length 11
  19:58:38.816475 IP localhost.9999 &gt; localhost.39278: Flags [.], ack 44, win 342, options [nop,nop,TS val 3575440313 ecr 3575440313], length 0
  19:58:39.817500 IP localhost.39278 &gt; localhost.9999: Flags [P.], seq 44:55, ack 1, win 342, options [nop,nop,TS val 3575441315 ecr 3575440313], length 11
  </code></pre>
  
  <p>So, seems like the broker sends me a message. But why my <code>test_class</code> does not recognize a message ? Why <strong>"Resource temporarily unavailable"</strong> error rised ?  </p>