title: select with other objects than sockets on windows
body: <p>I'm facing an issue doing a select() call waiting on a socket + pipe.</p>
  
  <p>I know there are already some topics on that but I have read lots of things and their opposite and I can't figure out what is the best solution for my problem.</p>
  
  <p>The best for me would be to use WaitForMultipleObjects() listening on these two objects but when I try to call it only on the WSAEvent object, it fails and last error catch is code 6 (Invalid Handle).</p>
  
  <pre><code>WSAEVENT sockEvent = WSACreateEvent();
  sockEvent = WSAEventSelect(fd, sockEvent, FD_WRITE);
  HANDLE *pHandles = &amp;sockEvent;
  DWORD dwEvent = WaitForMultipleObjects(1, pHandles, FALSE, amqp_time_ms_until(deadline));
    switch (dwEvent) 
      { 
        // ghEvents[0] was signaled
        case WAIT_OBJECT_0 + 0: 
          // TODO: Perform tasks required by this event
          return AMQP_STATUS_OK;
  
          // ghEvents[1] was signaled
        case WAIT_OBJECT_0 + 1: 
          // TODO: Perform tasks required by this event
          return AMQP_STATUS_POLL_EXTERNAL_WAKE;
  
        case WAIT_TIMEOUT:
          return AMQP_STATUS_TIMEOUT;
  
          // Return value is invalid.
        default: 
          return AMQP_STATUS_SOCKET_ERROR; 
      }
  </code></pre>
  
  <p>So WaitForMultipleObjects doesn't seems to Work with WinSocks events, however I have already seen some examples on the net working with it.
  And the of WSACreateEvent documentation (<a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms741561%28v=vs.85%29.aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/windows/desktop/ms741561%28v=vs.85%29.aspx</a>) says this :</p>
  
  <blockquote>
    <p>Windows Sockets 2 event objects are system objects in Windows
    environments. Therefore, if a Windows application wants to use an
    auto-reset event rather than a manual-reset event, the application can
    call the CreateEvent function directly.</p>
  </blockquote>
  
  <p>This doesn't mean that WSAEvent are based on regular windows events ? If it's the case why it doesn't work with WaitForMultipleObjects ? The doc says it can handle regular events.</p>
  
  <p>Thanks for helping.</p>