🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: WSAGetLastError return always 6

#1187
From: Remy Lebeau (TeamB)
Date: Tue, 27 Feb 2007 01:59
68 lines
3616 bytes
"Eduardo Jauch" <eduardo.jauch@gmail.com> wrote in message
news:45e380bc@newsgroups.borland.com...

> Because I know the pages I'm accessing, I don't need to look to
these
> parameters.

Oh yes, you most certainly do!!!!  That is the ONLY way to use HTTP
properly.  If you do not follow the rules, even the slightlest changes
to the HTML could cause your code to fail very very badly.  You MUST
use the sizes and types that the server actually specifies.  This is
EXTREMELY important if you ever want to use keep-alives properly as
well, as you don't want to leave unfinished data in the socket buffers
between requests.

Seriously, the more you push forward on this topic, the more I see how
wrongly you are implementing everything.  You really should consider
using pre-made libraries for everything.  If you want portability, you
should look at libcurl (http://curl.haxx.se) and other cross-platform
libraries.

> The page that agendar_recv() access (look to my other post),
> always return a chunked page.

You are most certainly NOT handling HTTP chunked data at all !!  You
are not even looking at the "Transfer-Encoding" header, which tells
you whether the data is chunked or not in the first place.  If it is
NOT chunked, then you must use the "Content-Length" header to know how
many bytes to read.

> So, I read the buffer until I get the final like this: "0\r\n\r\n"
tnat
> indicates the end of the response (according with RFC2616)

You are not even close to implementing what the RFC says to do in
regards to handling chunked data.

> And it works.

Only because you are completely ignoring everything.

> If I try to read anything after this, the recv stay many seconds
> waiting fod data and finaly return 0.

As it should be, because there is no data sent after the final chunk
block.  You need to stop reading after you receive that block.  But
you are not stopping, because you are not handling chunked reading
correctly to begin with.

> Then, I understand correct the bcb 6 help :)

No, you don't understand, not even close.  The code you have shown so
far demonstrates that.  You are FAR away from having a working HTTP
implementation.

> At each 91 requests, the server close the connection... :)
<snip>
> Say that to the server. Look's like he don't know that ;)

More like you don't know how to use sockets correctly in the first
place.  Your code is very very wrong for what you are attempting to
do.  You seriously need to clean it up ALOT just to get the basic TCP
functionality working correctly, let alone the HTTP functionality on
top of it.


Gambit
Technical Details
Message-ID: <45e38fa2$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.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>

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>
Subject: Re: WSAGetLastError return always 6
Date: Mon, 26 Feb 2007 17:59:01 -0800
Lines: 70
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: <45e38fa2$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1172541346 75.83.34.171 (26 Feb 2007 17:55:46 -0800)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail