🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: retrieve a simple web page by knowing its URL

#4467
From: Remy Lebeau (TeamB)
Date: Wed, 09 Feb 2005 18:17
35 lines
2310 bytes
"Stefano Bonifazi" <stefboombastic@email.it> wrote in message
news:4209d747@newsgroups.borland.com...

>                     "Host: "+IP+"\r\n"

You should be specifying the host name, not the IP.

>  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.

> 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.


Gambit
Technical Details
Message-ID: <420a530c@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4209d747@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: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <4209d747@newsgroups.borland.com>
Subject: Re: retrieve a simple web page by knowing its URL 
Date: Wed, 9 Feb 2005 10:17:57 -0800
Lines: 37
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: 68.69.17.41
Message-ID: <420a530c@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1107972876 68.69.17.41 (9 Feb 2005 10:14:36 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail