Microsoft KB Archive/240398

{|
 * width="100%"|

PRB: InternetReadFile May Block Receiving Last Buffer of Data

 * }

Q240398

-

The information in this article applies to:


 * Microsoft Windows CE Operating System versions 2.0, 2.11

-

SYMPTOMS
The InternetReadFile Application Programming Interface (API) may block on Windows CE. Usually such behavior occurs while reading the last buffer of data in a loop, using code similar to this (error checking code is omitted):

do {    InternetReadFile (..., &dwRead); } while (dwRead != 0)

CAUSE
This problem is caused by using "HTTP/1.1" as the forth parameter (lpszVersion) in HttpOpenRequest API. WinInet on Windows CE version 2.00 and 2.11 supports only HTTP version 1.0.

RESOLUTION
The solution is to use "HTTP/1.0" for lpszVersion parameter or HTTP_VERSION (defined in WININET.H).

STATUS
This behavior is by design.

MORE INFORMATION
When HTTP/1.1 is used, the Web server uses a keep-alive connection and therefore does not close the socket after sending all the data to the client. Because HTTP 1.1 is not supported in WinInet on Windows CE 2.00 and 2.11, InternetReadFile waits to receive FIN from the server (the Transmission Control Protocol [TCP] packet sent by the Web server, indicating connection tear-down) and therefore hangs. After the default timeout, InternetReadFile may return with a timeout error code displayed.

NOTE: Nagling provides a big performance boost in low-bandwidth and high-latency situations (such as many user connections to the Internet). It should not be bypassed lightly.