On Jan 10, 6:58 pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
> > Greetings,
>
[quoted text clipped - 42 lines]
>
> Pete
Pete,
You bring up some good points, thanks. I did re-check my code and
there is no way for it to exit the loop except to press cancel (which
sets a flag to true and is checked in the loop) or for zero bytes to
be read from the ResponseStream. FYI, this is the resposne stream
from HttpWebRequest.
It is possible that it is reading zero bytes because the connection is
closing prematurely, but this is suppose to generate an exception
which I check for (I actually check for any exception). So I don't
know what could be causing the ResponseStream to return zero bytes if
it hasn't reached the end of the content (according to the
ContentLength anyway). I've already coded in a re-check for when this
happens, but I was hoping to figure out WHY it is happening.
Anne,
Unfortunately the files aren't public, sorry.
Thanks for your help guys. IF you have any more insight, I'd be most
greateful.
Peter Duniho - 12 Jan 2008 00:47 GMT
> [...]
> It is possible that it is reading zero bytes because the connection is
> closing prematurely, but this is suppose to generate an exception
That's not true. You'll get an exception if the connection is _reset_,
but if it's simply closed then you get a 0 byte receive.
> which I check for (I actually check for any exception).
> So I don't
> know what could be causing the ResponseStream to return zero bytes if
> it hasn't reached the end of the content (according to the
> ContentLength anyway).
As I said, there is no network requirement that the number of bytes
delivered by the server before closing the connection is identical to the
number of bytes the server advertised in the HTTP response. The
advertised length is just that: an advertisement. The network side of
things doesn't enforce it.
One would expect a correctly-behaving HTTP server to provide the bytes as
advertised, but servers don't always behave, and on top of that some ISPs
are known to mess with TCP connections, including doing something like
closing it for no good reason.
> I've already coded in a re-check for when this
> happens, but I was hoping to figure out WHY it is happening.
That's an admirably goal. But the only way you can do that is by doing
some debugging. You need to monitor the network traffic at both ends and
figure out who is closing the connection. Once you've identified that,
then you can look at why. Unfortunately, a vague problem description is
not enough information for anyone else in this newsgroup to answer the
question. Only first-hand knowledge will do.
Pete