troubleshooting Question

I am writting an application which talks ( reads and rwrites ) from a serial port. I am using overlapped file I/o

Avatar of JoeBarryTwinstar
JoeBarryTwinstar asked on
System Programming
4 Comments1 Solution202 ViewsLast Modified:
I am writting an application which talks ( reads and rwrites ) from a serial port. I am using overlapped file I/o asynchronously. I keep getting an invalid handle message from my WaitForMultipleObjects code and cannot figure out why. Here is the offending code:

            DWORD result = ::WaitForMultipleObjects(2, waiters, FALSE, INFINITE);
            switch(result)
               { /* wait */
                case WAIT_OBJECT_0:  // shutdown
                              {
                    ::CancelIo(parms->hCom);
                    shutdown = ERROR_SUCCESS;  // clean shutdown
                    running = FALSE;
                    continue;
                              }
                case WAIT_OBJECT_0 + 1: // I/O complete
                              {
                    ok = ::GetOverlappedResult(parms->hCom, &ovl, &bytesRead, TRUE);  
                    if(!ok)
                       { /* GetOverlappedResult failed */
                        DWORD err = ::GetLastError();
                        running = FALSE;
                        continue;
                       } /* GetOverlappedResult failed */
                    break;
                              }
                default:
                    { /* trouble */
                     shutdown = ::GetLastError();

/////// This GetLastError returns 6, which means invalid handle. Is it the CEvent handle, or my serial port handle?

I am stumped.

Thanks
                     ASSERT(FALSE); // failure
                     running = FALSE;
                     continue;
                    } /* trouble */
               } /* wait */  
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros