title: Detecting if a COM port has closed
body: <p>I am reading a Bluetooth COM port, getting data from a microcontroller.
  After initializing the port, I am using this to read the port:</p>
  
  <pre><code>while(1)
  if(WaitCommEvent(com_hnd, &amp;dwEventMask, NULL))
  </code></pre>
  
  <p>This works fine, but if I close the COM port, the program will wait forever in this loop, without detecting the fact that the COM port is gone (I have an else for that if(), where I check for errors).</p>
  
  <p>How can I check and see if it still open?</p>