Search code examples
winapiwininet

Why does calling the InternetReadFileEx function with IRF_NO_WAIT flag still wait?


I'm using a synchronous wininet request and calling InternetReadFileEx() with the IRF_NO_WAIT flag, but the function still blocks waiting for data. Why is that?


Solution

  • In the MSDN docs, the meaning of IRF_NO_WAIT is described as:

    Do not wait for data. If there is data available, the function returns either the amount of data requested or the amount of data available (whichever is smaller).

    Mysteriously, it leaves the case where there is not data available undefined. Apparently, if there is no data, it blocks until there is some.