title: non blocking socket in c++
body: <p>I am writing client in c++ which client get response on two different ports. 
  I am listening to one port in main thread while I have created other thread (posix based) like this:</p>
  
  <pre><code>void *receiveFunc(void *ptr)
  {
      try {
          while ( true ) {
              svr_sock &lt;&lt; svr_data;
              cout&lt;&lt;svr_data&lt;&lt;endl;
          }
      } catch ( SocketException&amp; ) {}
  }
  </code></pre>
  
  <p>but when it enters into the this thread it never comes out until I have received something on the socket.</p>
  
  <p>How can I overcome this problem?</p>