Article View: borland.public.cppbuilder.internet.socket
Article #1192Re: WSAGetLastError return always 6
From: Remy Lebeau (TeamB)
Date: Tue, 27 Feb 2007 07:08
Date: Tue, 27 Feb 2007 07:08
63 lines
3346 bytes
3346 bytes
"Eduardo Jauch" <eduardo.jauch@gmail.com> wrote in message news:45e3a6cf@newsgroups.borland.com... > This app that I'm doing, is for my personal use only. I don't mind > if a change on the page that I access will make me re-write the code. You don't have to do that, though. If you implement it properly in the first place, then the code will automatically adapt to whatever content it receives, so you won't have to re-write the code each time a change occurs. > > 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. > > > > I sow every header of the pages that I access to see if it was chunked > or not, to make the code without the need to verify this every time I > access the page. Is bad programing, but will work until they change the > page, and no ptoblem with that :) Chunking is a server-side configuration. Many systems don't use chunked transfers. It actually produces more overhead than sending the raw data as-is instead. Chunking tends to be used only on systems that support partial downloads, such as for resuming broken transfers. Not all systems support that, though. > Oh... > But I'm stopping :) But not as quickly as you could be. You seem to be very fond of writing fast running code, but you are not handling the HTTP responses in a way that allows you to exit as soon as the response is finished. You are sitting there waiting for a timeout that you do not need to wait for if you take the true data length into account properly like the RFCs say to do. > If you look at the code, you'll see this: Which is still the completely wrong thing to do. > This is at the end of the loop of the recv. > The last line "if(strcmp" is exactly verifying if the chunked block is > the last (because this page is chunked) But you are not reading the individual chunks properly at all. Which is why you are getting into a scenerio that relies on a waiting loop to time out. Gambit
Technical Details
Message-ID:
<45e3d748@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<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>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> Subject: Re: WSAGetLastError return always 6 Date: Mon, 26 Feb 2007 23:08:10 -0800 Lines: 65 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: <45e3d748@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1172559688 75.83.34.171 (26 Feb 2007 23:01:28 -0800) Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail