Introduction to Overlapped I/O#
Overlapped I/O is a Win32 technique where you ask the operating system to transfer data for you and notify you when the transfer is done. It lets your program keep handling other work while I/O is in progress. It’s also known as non-blocking I/O or asynchronous I/O.
Suppose a thread issues an asynchronous I/O request to a device. The request is handed to the device driver, which is responsible for carrying out the actual I/O operation. While the driver waits for the device to respond, the application’s thread is not suspended waiting for the I/O request to complete; it keeps running and does other useful work.
It comes in four flavors of asynchronous I/O, ranging from simple to advanced:
- Signaled File Handles
- Signaled Event Objects
- Asynchronous Procedure Calls (APC)
- I/O Completion Port (IOCP)
Prerequisites for Using Overlapped I/O#
To access a device asynchronously, we need to call the Win32 CreateFile function and open the device with the FILE_FLAG_OVERLAPPED flag in the dwFlagsAndAttributes parameter. This flag tells the operating system that we want to access the device asynchronously.





