🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #1196

Re: WSAGetLastError return always 6

#1196
From: Eduardo Jauch
Date: Tue, 27 Feb 2007 21:46
84 lines
3938 bytes
Remy Lebeau (TeamB) escreveu:
> "Eduardo Jauch" <eduardo.jauch@gmail.com> wrote in message
> news:45e4284e$1@newsgroups.borland.com...
> 
>> It comes a first part, that contains the header and an hexa that say
>> the number of bytes to read. Then on the next loop, I receive a new
>> chunk with a new hexa that says the length of the new chunk, a
>> third time this occour and on the fourth, the signal that the send
> of
>> chunked data ends is present "0\r\n\r\n". So I quit the loop because
>> there not more data to read...
> 
> That is how chunked transfers work, but that is not how your earlier
> code was actually reading chunked data.  You were not reading the
> chunked sizes at all.  You were reading the incoming data in arbitrary
> byte sizes into a buffer without any care whatsoever to the actual
> content of the transfer, and then trying to verify the last chunk
> only.  A proper transfer should be performing the following sequence
> instead:
> 
>     send the request
>     read a single line
>     verify the response code in the line
>     loop
>         read a line
>         if line is empty then break
>         store the line into a header list
>     end
>     if list contains 'Transfer-Encoding: chunked' header then
>     begin
>         loop
>             read a line
>             extract chunk size from the line
>             if chunk size is 0 then break
>             read number of bytes specified
>             store bytes into buffer
>             read an empty line
>         end
>         read an empty line
>     end
>     else if list contains 'Content-Length' header then
>     begin
>         read number of bytes specified
>         store bytes into buffer
>     end
>     else
>     begin
>         loop
>             read as many bytes as are currently available
>             if disconnected then break
>             store bytes into buffer
>         end
>     end
> 
>> And what I must to do?
> 
> See above.
> 
> 
> Gambit
> 
> 
I understand.

I'm not readind the chunk length. But this is because the char[] where I 
store the page is far bigger than the page I receive...

I know... Bad pratice.

but to do this is time consuming. I first do a code that does something 
similarly... But the "speed" was slower that if I "force" to do like I'm 
doing now :)

But I'll implement the code with the knowledge and tips that you show 
me, at last to verify if anything changed...

For now at last.

But all you said was good advise of course, and I thank you :)

I'll do tests with the code for long time anyway, and problably will 
implement most of what was discussed here :)

Thanks Gambit.
Technical Details
Message-ID: <45e4a68c$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <45e24baa@newsgroups.borland.com> <45e31e54$1@newsgroups.borland.com> <45e34585$1@newsgroups.borland.com> <45e358b3$1@newsgroups.borland.com> <45e380bc@newsgroups.borland.com> <45e38fa2$1@newsgroups.borland.com> <45e3a6cf@newsgroups.borland.com> <45e3d748@newsgroups.borland.com> <45e4284e$1@newsgroups.borland.com> <45e47101$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,ead06e5a7c488245
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Tue, 27 Feb 2007 18:46:47 -0300
From: Eduardo Jauch <eduardo.jauch@gmail.com>
User-Agent: Thunderbird 1.5.0.9 (Windows/20061207)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.internet.socket
Subject: Re: WSAGetLastError return always 6
References: <45e24baa@newsgroups.borland.com> <45e31e54$1@newsgroups.borland.com> <45e34585$1@newsgroups.borland.com> <45e358b3$1@newsgroups.borland.com> <45e380bc@newsgroups.borland.com> <45e38fa2$1@newsgroups.borland.com> <45e3a6cf@newsgroups.borland.com> <45e3d748@newsgroups.borland.com> <45e4284e$1@newsgroups.borland.com> <45e47101$1@newsgroups.borland.com>
In-Reply-To: <45e47101$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 201.14.27.130
Message-ID: <45e4a68c$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1172612748 201.14.27.130 (27 Feb 2007 13:45:48 -0800)
Lines: 84
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail