Win32 select/poll/eof/ANYTHING!?!?!

Posted by Andrew on Stack Overflow See other posts from Stack Overflow or by Andrew
Published on 2010-05-28T03:02:13Z Indexed on 2010/05/28 3:11 UTC
Read the original article Hit count: 286

Filed under:
|
|
|
|

Using the standard Win32 file I/O API's (CreateFile/ReadFile/etc), I'm trying to wait for a file to become readable, or for an exception to occur on the file. If Windows had any decent POSIX support, I could just do:

select(file_count, files_waiting_for_read, NULL, files_waiting_for_excpt, NULL, NULL);

And select will return when there's anything interesting on some of the files. Windows doesn't support select or poll. Fine. I figured I could take the file and do something like:

while(eof(file_descriptor))
{
    Sleep(100);
}

The above loop would exit when more data is available to be read. But nope, Windows doesn't have an equivalent of eof() either! I could possibly call ReadFile() on the file, and determine if it's at the eof that way. But, then I'd have to handle the reading at that point in time -- I'm hoping to simply be able to figure out that a file is readable, without actually reading it.

What are my options?

© Stack Overflow or respective owner

Related posts about c++

Related posts about visual-studio