Article View: borland.public.cppbuilder.internet.socket
Article #4471Re: retrieve a simple web page by knowing its URL
From: Stefano Bonifazi
Date: Thu, 10 Feb 2005 08:14
Date: Thu, 10 Feb 2005 08:14
52 lines
3050 bytes
3050 bytes
Thank You Mr. Lebeau, "Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message news:420a530c@newsgroups.borland.com... > You should be specifying the host name, not the IP. I think You're right as always, that's the first thing I noticed in Mr. Aletto working code! IE used 127.0.0.1 with my " header sniffer" server ... but I had used http://127.0.0.1:8000/ in its url to make it log with my server (working on port 8000) :-) > >> SDBLogClientSocket->Socket->SendText(Request); > > You are not checking the return value of SendText() to make sure that the > whole request has actually been sent. The return value tells you how many > bytes were actually sent. > > If SendText() returns a value less then the length of the string, then you > have to call SendText() again to finish sending the same string. Make > sure > to remove the characters that were already sent before sending the string > again. > > If SendText() returns -1, then use WSAGetLastError() to know whether the > send actually failed, or just blocked. If WSAGetLastError() returns > WSAEWOULDBLOCK, you have to wait until the OnWrite event is triggered > before > you can send data again. If WSAGetLastError() does not return > WSAEWOULDBLOCK, then an actual socket error occured, the OnError event > will > be triggered, and the socket will be disconnected automatically. > Yes ... it's a my terrible custom to not check the SendText result ... I use to test my projects in my little local LAN, so that function can always send all the buffer at once ... >> It connects fine but then I receive the classical HTTP 404 error >> "The page cannot be found". > > Correct, because your request data is wrong to begin with. Specifically, > your Host header value is wrong. You must use the hostname, not the IP, > or > else the server refuses the request with an error. > Thank You again! Now I can get rid of the (not working) Indy component in my project! Stefano B.
Technical Details
Message-ID:
<420b17ca@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news.moat.net!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<4209d747@newsgroups.borland.com> <420a530c@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,474753b63a76f917 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Stefano Bonifazi" <stefboombastic@email.it> Newsgroups: borland.public.cppbuilder.internet.socket References: <4209d747@newsgroups.borland.com> <420a530c@newsgroups.borland.com> Subject: Re: retrieve a simple web page by knowing its URL Date: Thu, 10 Feb 2005 09:14:06 +0100 Lines: 54 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 212.141.200.118 Message-ID: <420b17ca@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1108023242 212.141.200.118 (10 Feb 2005 00:14:02 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news.moat.net!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail