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

  • Home
  • SEARCH
  • 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 320947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:48:02+00:00 2026-05-12T08:48:02+00:00

The situation: I was using HttpWebRequest.BeginGetResponse as documented in msdn. I had a timer

  • 0

The situation: I was using HttpWebRequest.BeginGetResponse as documented in msdn. I had a timer sending the request every ten seconds. I received xml-structured information, when I tested it.

The result: Being at the customers place and having that tool running I received incomplete (and therefore unparsable) xmls (each about 4KB). I could check in a browser and see it completely (obviously a synchronous request through the browser?!). I used the header information about the content length to size my receiving buffer.

What caused it? I don’t know. The data is fairly small. Still I used the ThreadPool.RegisterWaitForSingleObject approach described at developer fusion to define a timeout, I chose ten seconds as well for the timeout. Maybe that wasn’t a smart decision, it probably should be smaller that the timer interval. The thing is, I cannot test it again under those conditions. It was at a production site, where I had not insight to the network setup. The reguests ran just fine at the same time from home.

I’m not very experienced in that field, but what happens when a timer triggers a new request before the response stream has been fully received, because e.g. the timeout time is equal to the timer interval? Any other hints what could be the bottle neck here?

  • 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-12T08:48:02+00:00Added an answer on May 12, 2026 at 8:48 am

    How are you receiving data? Are you reading data through a stream? And are you using the contentsize returned as an input parameter to Stream.Read?
    A feature of Stream.Read that is not completely obvious is that it is not guaranteed to return the amount of data that you requested.
    When you call the following function

    public abstract int Read(byte[] buffer, int offset, int count )
    

    it will return how much data was actually read. So you may ask it to read 1000 and it return 400, then there is still 600 bytes left to read.
    That means that you have to continue calling Read until it returns 0 (which means that there is no more data in the stream).

    I would also say that you should not use the content length header information to size your buffer. Instead you should create a dynamically sized buffer (e.g. by using a MemoryStream object) and read from the response stream until it returns 0. At least, that is how I would do it. Then your solution will continue to work, if the server changes implementation so it no longer sends that response header.
    Or even better, since you are loading XML, create an XmlDocument, and ask it to load directly from the Http response stream.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got an unusual situation: I'm using a Linux system in an embedded situation
using jython I have a situation where emails come in with different attachments. Certain
I have a situation where I am using wpf data binding and validation using
I have a situation where I'm loading some content using a URLLoader but the
I am curious as to what others are using in this situation. I know
I have a situation where I have to take input from the user using
I am trying to POST an attachment to CouchDB using the HttpWebRequest. However, when
The situation: Using a off-the-shelf PHP application, I have to add in a new
I have the following situation: using a classical Java server (using ServerSocket) I would
Ok here is the situation (using PHP/MySQL) you are getting results from a large

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.