I want to make asynchronous read on stdin in Windows with I/O Completion Ports but this code doesn't works :
#include <windows.h>
#include <stdio.h>
#pragma comment(lib, "Kernel32.lib")
int main() {
HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
DWORD number;
HANDLE iocp = CreateIoCompletionPort(handle, NULL, 0, 0);
if(iocp == NULL) {
printf("error : %d\n", GetLastError());
}
}
I get the error 87 : ERROR_INVALID_PARAMETER
CreateIOCompletionPort cannot be used directly with stdin/stdout. Check this. Either use a thread, or redirect stdin/stdout to named pipes.