🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: WSAGetLastError return always 6

#1199
From: Remy Lebeau (TeamB)
Date: Wed, 28 Feb 2007 00:45
55 lines
3559 bytes
"Eduardo Jauch" <eduardo.jauch@gmail.com> wrote in message
news:45e4c107$1@newsgroups.borland.com...

> Receive the whole data first. All of them is loaded into "html",
> that is a char [].

Which is STILL the wrong thing to do!!!  You are not even ensuring
that your char[] really is large enough to hold everything the server
may send to you, and at worse you are overallocating more memory than
you really need right now.

> What I really do is search the first "<select " on the page. When I
> find it, I look for the second "<option " (if it exists) and so on
until
> I find the first "</select>"

That is very error prone.  Because of the nature of chunked transfers,
you are not even guaranteed to have such complete strings in your
buffer because you are not stripping out the chunked information
first.  You could have "<sel"+chunk+"ect" and the like, which would
cause your searching algorithm to fail.  You MUST handle chunked
transfers correctly in order to ensure the integrity of the data you
want to parse.  I don't know how to make this any clearer to you.

> This is why I do such horrible code...

Your code is horrible not because of HOW UGLY it is to look at, but
because how INCOMPLETE it is to begin with.  There are so many things
you are doing wrong with it that you are not guaranteed to end up with
the data that you are expecting.

> And why I don't mind to read the chunked data etc...

The presence of chunking is not an issue.  Your handling of chunking,
on the other hand, is very much an issue.

> And because the information that I want always come only
> with the last chunk, I don't bother with the rest.

That is also not a guarantee, either.  You really don't seem to be
grasping what HTTP is actually sending you.  So you are going to keep
handling it all wrong.

> sometimes the data that came is bigger than normal, and some of that
> come in the chunk right before the last.

All the more reason why you NEED to handle chunking, and in fact any
HTTP transfer in general, properly from the very beginning.  But you
are refusing to do that much.  Obviously, you want a broken,
error-prone, dangerous implementation, so that is your choice.  I'm
done debating this discussion any further.


Gambit
Technical Details
Message-ID: <45e4d0c0$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> <45e4a68c$1@newsgroups.borland.com> <45e4b0c8$1@newsgroups.borland.com> <45e4c107$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
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
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> <45e4a68c$1@newsgroups.borland.com> <45e4b0c8$1@newsgroups.borland.com> <45e4c107$1@newsgroups.borland.com>
Subject: Re: WSAGetLastError return always 6
Date: Tue, 27 Feb 2007 16:45:56 -0800
Lines: 57
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 75.83.34.171
Message-ID: <45e4d0c0$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1172623552 75.83.34.171 (27 Feb 2007 16:45:52 -0800)
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