title: How to let a thread which blocks on recv() exit gracefully?
body: <p>There is a thread likes this:  </p>
  
  <pre><code>{  
      ......    
      while (1)
      {
          recv(socket, buffer, sizeof(buffer), 0);
          ......
      }
      close(socket);           
  }  
  </code></pre>
  
  <p>Because the thread is blocking on recv() call, how can I let the thread exit gracefully? </p>