I want to determine if there is an expected input value for stdin on Windows.
I use the following general structure on Linux:
fd_set currentSocketSet;
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 0;
int result = 1;
while (result > 0){
FD_ZERO(¤tSocketSet);
FD_SET(STDIN, ¤tSocketSet);
result = select(STDIN+1, ¤tSocketSet, NULL, NULL, &tv);
if (result == -1){
printf("Network Error -- select errored with id=%d.\n", errno);
return;
} else if (result > 0){
}
}
Note. I don't want to deal with keyboard and keyboard functions like kbhit. I want to do what I asked. I also don’t want the third-party library to do this either, I would like the call from the Windows library to trigger an answer.
Note # 2: In the windows, the code above is with error code Windows 10038 "The operation was attempted for something that is not a socket", which probably means that the windows do not support STDIN selection.
source
share