Checking for input waiting at stdin (not kbhit())

Started by
0 comments, last by kieren_j 20 years ago
Hey there, I''ve been searching for a way to check if input is waiting at stdin without using kbhit(), but I''m fairing poorly. Any ideas? It seems kbhit() only checks if a key was pressed A little background.. App A creates some pipes (CreatePipe) and creates an instance of App B, with redirected stdin/stdout (App A can send data to it''s stdin, read data from it''s stdout)... This works fine. However, App B is supposed to respond to what''s sent to it in a nice manner. Effectively, App A sends it commands.. App B is supposed to check regularly if there is any input to process. However, kbhit() doesnt work on stdin, it seems it only works with the keyboard... And getch() or ReadFile on stdin (which I retrieve in App B using GetStdHandle(STD_HANDLE_STDIN)) would cause a block. Another strangeness to note, PeekNamedPipe() doesnt work on the returned handle from GetStdHandle(STD_HANDLE_STDIN).. It says ''invalid handle'', though GetStdHandle() doesn''t return INVALID_HANDLE_VALUE, it returns "3". *shrug* Can anyone help me out here? Any ideas? Thanks... K
Advertisement
Use PeekConsoleInput() - it doesn''t block if there''s no data to be read.

This topic is closed to new replies.

Advertisement