Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6845381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:29:37+00:00 2026-05-27T00:29:37+00:00

Synchronous operation. GetLastError = 0, WinHttpQueryDataAvailable itself returns TRUE (i.e. OK) yet the number

  • 0

Synchronous operation. GetLastError = 0, WinHttpQueryDataAvailable itself returns TRUE (i.e. OK) yet the number of bytes to read = 0

Any idea what this means? It normally works fine (reading JPEG stream from a camera), but occasionally gets stuck here (which prompts the code to reconnect).

According to MSDN, WinHttpQueryDataAvailable shouldn’t have returned: “If the session is synchronous, the request waits until data becomes available.”

Code extract here:

g_HSession = WinHttpOpen( L"Jet", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0 );

ResultsOk = WinHttpSendRequest( 
    hRequest,
    WINHTTP_NO_ADDITIONAL_HEADERS,
    0, WINHTTP_NO_REQUEST_DATA, 0, 
    0, 0);

// End the request.
if (ResultsOk)
{
    ResultsOk = WinHttpReceiveResponse( hRequest, NULL );

    DWORD BytesToRead = 0;

    if (WinHttpQueryDataAvailable( hRequest, &BytesToRead ))
    {
        if (BytesToRead) // THIS IS SOMETIMES 0 - seems wrong to me
        {
            if (WinHttpReadData( hRequest, pReadPos, min(BytesToRead, (unsigned)SizeRemaining), &NumRead ))
            {
                ...etc!
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:29:38+00:00Added an answer on May 27, 2026 at 12:29 am

    Underlying HTTP response has been successfully received, but it was empty (that is, zero length response) or all the data has been read and closed. WinHttpQueryDataAvailable indicates this by returning TRUE still showing zero count of data available.

    Think of:

    HTTP/1.0 200 OK
    Content-Length: 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When using a synchronous I/O such as fread which is buffered, the read operations
I have not been able to find a way to cancel/terminate asynchronous read operation
Events are synchronous in C#. I have this application where my main form starts
I have a synchronous web service call that returns a message. I need to
I'm attempting to perform a synchronous write/read in a demux-based client application with MINA
Asynchronous operations with I/O Completion Ports return 0 bytes transferred, although the I/O operations
I'm looking to implement a synchronous and asynchronous version of a method within a
I'm using super-simple synchronous C# Sockets for an assignment. The assignment is to create
I want to use the <operation>Asnyc methods rather than the Begin<operation>/End<operation> on my WCF
According to the book Programming Clojure refs manage coordinated, synchronous changes to shared state

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.