Re: Connection close in HTTP server
- From: "Alexander Nickolov" <agnickolov@xxxxxxxx>
- Date: Mon, 5 Dec 2005 10:48:30 -0800
Well, you were told (by the zero return value) that the connection
is closed, so you are supposed to close your end of the socket.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Nuno Magalhaes" <nunommagalhaes@xxxxxxxxxxx> wrote in message
news:1133584545.213275.316780@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>I don't get it. My Receive function doesn't block and doesn't throw
> exceptions when there is no more to read, it just keeps returning 0
> over and over when it reaches the end. Do you know why? (only a Send
> will throw an exception)
> (take a look at the code below)
>
> while(true)
> {
> try
> {
> int
> j=socket.Receive(bytes,receivedOffset,socket.Available,SocketFlags.None);
> receivedOffset+=j;
> }
> catch(Exception)
> {
> break;
> }
> }
>
>
> Alexander Nickolov wrote:
>> Very simple - don't Send. Receive will tell you when the
>> connection is closed.
>>
>> --
>> =====================================
>> Alexander Nickolov
>> Microsoft MVP [VC], MCSD
>> email: agnickolov@xxxxxxxx
>> MVP VC FAQ: http://www.mvps.org/vcfaq
>> =====================================
>>
>> "Nuno Magalhaes" <nunommagalhaes@xxxxxxxxxxx> wrote in message
>> news:1133534266.092059.131860@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>> > How do I get all the data from the server if in the last chunk the
>> > server closes the connection?
>> > I'm doing a loop that consists on a:
>> > Socket.Receive
>> > Socket.Send
>> > The Send function is to check if the socket is alive and the receive
>> > function receives the data at specified offsets. If the data arrives
>> > between Receive and Send functions and the connection is closed by the
>> > server (as described in the HTTP RFC) I can't get the last bytes of the
>> > html page anymore (because the socket gets dead with the send
>> > function).
>> >
>> > Does anyone knows a solution for this problem? Someone must have
>> > implemented a simple HTTP browser from the "ashes"...
>> >
>> > Thanks in advance,
>> > Nuno Magalhaes.
>> >
>
.
- References:
- Connection close in HTTP server
- From: Nuno Magalhaes
- Re: Connection close in HTTP server
- From: Alexander Nickolov
- Re: Connection close in HTTP server
- From: Nuno Magalhaes
- Connection close in HTTP server
- Prev by Date: LSP HTTP redirecting
- Next by Date: Re: Wrapping TCP communications in HTTP
- Previous by thread: Re: Connection close in HTTP server
- Next by thread: Structure MIB_IFROW
- Index(es):
Relevant Pages
|