title: How to cancel waiting in select() on Windows
body: <p>In my program there is one thread (receiving thread) that is responsible for receiving requests from a TCP socket and there are many threads (worker threads) that are responsible for processing the received requests. Once a request is processed I need to send an answer over TCP. </p>
  
  <p>And here is a question. I would like to send TCP data in the same thread that I use for receiving data. This thread after receiving data usually waits for new data in <code>select()</code>. So once a worker thread finished processing a request and put an answer in the output queue it has to signal the receiving thread that there are data to send. The problem is that I don't know how to cancel waiting in <code>select()</code> in order to get out of waiting and to call <code>send()</code> .</p>
  
  <p>Or shall I use another thread solely for sending data over TCP?</p>
  
  <p><strong>Updated</strong></p>
  
  <p>MSalters, Artyom thank you for you answers! </p>
  
  <p>MSalters, having read your answer I found this site: <a href="http://www.winsocketdotnetworkprogramming.com/winsock2programming/winsock2advancediomethod5.html" rel="noreferrer">Winsock 2 I/O Methods</a> and read about <code>WSAWaitForMultipleEvents()</code>. My program in fact must work both on HP-UX and Windows I finally decided to use the approach that had been suggested by Artyom.</p>