this is my first small own created internetprogram:
procedure TForm1.SpeedButton1Click(Sender: TObject);
var HTMLstring : string;
begin
with IdHTTP1 do
begin
host := 'http://www.pop.com/';
port := 80;
HTMLstring := ConnectAndGetAll;
Try
// still nothing
finally Disconnect;
end;
end;
But it doesn't work. Always appears an (Debugger-)Exception which says:
'Socket Error # 11001.... host not found'
Sometimes the exception also says only: Socket Error # 11004 - with no
further comment.
Where could be the mistake?
Second Question:
If i got this answered HTML-string finally (so i hope anyway *g*), how i can
show the contens like in an explorerwindow. I only have D7Personal and the
Indy-Components to solve this task.
Thanks in advance
asker
> 'Socket Error # 11001.... host not found'
WSAHOST_NOT_FOUND
(11001)
Host not found.
No such host is known. The name is not an official hostname or alias, or it
cannot be found in the database(s) being queried. This error may also be
returned for protocol and service queries, and means the specified name
could not be found in the relevant database.
> with IdHTTP1 do
> begin
> host := 'http://www.pop.com/';
> port := 80;
> HTMLstring := ConnectAndGetAll;
> Try
> // still nothing
> finally Disconnect;
> end;
> end;
That is not the correct way to request data from an HTTP server. You should
be using the TIdHTTP::Get() method instead:
HTMLstring := IdHTTP1.Get('http://www.pop.com/');
> But it doesn't work. Always appears an (Debugger-)Exception which says:
> 'Socket Error # 11001.... host not found'
That is because "http://www.pop.com" is not a valid host name for a TCP
connection. That is an HTTP URL, a very different issue altogether. The
correct hostname to use would have been "pop.com" instead.
> Sometimes the exception also says only: Socket Error
> # 11004 - with no further comment.
WSANO_DATA
(11004)
Valid name, no data record of requested type.
The requested name is valid and was found in the database, but it does not
have the correct associated data being resolved for. The usual example for
this is a hostname -> address translation attempt (using gethostbyname or
WSAAsyncGetHostByName) which uses the DNS (Domain Name Server), and an MX
record is returned but no A record - indicating the host itself exists, but
is not directly reachable.
Gambit
connecting the host is working now.
Now, my small beginner-program looks like this:
procedure TForm1.SpeedButton1Click(Sender: TObject);
var HTMLstring : string;
begin
with IdHTTP1 do
begin
host := 'pop.com';
Connect;
Try
HTMLstring := Get('pop.com');
// still nothing
end;
end;
But now, after connection there is another problem comes up in form of a
window which appears with the title: Sourcefile not found: IdHTTP.pas And
than it want to have the path for this file. But i don't have such a file. 3
days ago i downloaded Indy9 and such a file wasn't with it. What should i do
now. For what the program want to have this file?
Thanks
asker
connecting the host is working now.
Now, my small beginner-program looks so:
procedure TForm1.SpeedButton1Click(Sender: TObject);
var HTMLstring : string;
begin
with IdHTTP1 do
begin
host := 'pop.com';
port := 80;
Connect;
Try
HTMLstring := Get('pop.com');
// still nothing
finally Disconnect; // <---- this line IS existing, too
end;
end;
But now, after connection there is another problem comes up in form of a
window which appears with the title: Sourcefile not found: IdHTTP.pas And
than it want to have the path for this file. But i don't have such a file. 3
days ago i downloaded Indy9 and such a file wasn't with it. What should i do
now. Is there any hope for me?
Thanks
asker
But now after i tell this window the path of this IdHTTP.pas - file there
appears another Dubbuger-Exception:
An EIdHTTPProtocolException with the comment: 'HTTP/1.1 400 Bad Request'
Perhaps, do you have any idea to solve this next (small) problem too?
Thx
asker
*g*
> An EIdHTTPProtocolException with the comment:
> 'HTTP/1.1 400 Bad Request'
That is because you are passing the wrong URL to Get(). See my other reply.
Gambit
> host := 'pop.com';
> Connect;
There is no need to set the Host or call Connect() directly. TIdHTTP::Get()
handles everything internally.
> HTMLstring := Get('pop.com');
That is the wrong URL to pass to Get(). You should be passing in the full
HTTP URL, including the "http://" and "www." portions.
Your code should look like this:
procedure TForm1.SpeedButton1Click(Sender: TObject);
var
HTMLstring : string;
begin
HTMLstring := IdHTTP1.Get('http://www.pop.com');
// use HTMLstring as needed
end;
> But now, after connection there is another problem comes up in form of a
> window which appears with the title: Sourcefile not found: IdHTTP.pas
That suggests that an exception was thrown and the debugger is trying to
find IdHTTP.pas on your machine so that is can display the source code in
the editor.
> i don't have such a file. 3 days ago i downloaded
> Indy9 and such a file wasn't with it
Yes, it does have such a file. Indy is an open-source project, downloading
it includes the full source code, including the source for TIdHTTP.
Gambit
Now i also want to show this string like in an explorer-window. Do you know
a (D7Personal-) control or an Indy-Component which is able to do this? (Or
where else perhaps i can download such a component for showing these strings
in his correct way?)
Thanks a lot
asker
> Now i also want to show this string like in an explorer-window.
Please clearify. Do you mean that you want to actually display the HTML in
a browser window? If so, then Indy is not the right solution for you.
Borland has a TCppWebBrowser component for that instead. Or you can import
the IE ActiveX control manually.
Gambit
Thanks a lot once more
asker
The IDE has an "Import ActiveX Control" option in its menu.
Gambit
accordingly your good advice with the IDE i installed the
Microsoft Active Plugin (Version 1.0).
But during that Delphi warned me because this line (139):
property dispatch: IDispatch index -1 read GetIDispatchProp;
would hide a Member of the basic-Class??? What does it mean, is it very
important or should i ignore it?
And still this:-) Before i start a first run with this plugin-component, i
have to find a good second parameter for the Load-method i want to use:
procedure Load(const bstrUrl: WideString; bDeleteRegistry: SYSINT);
In 'bstrUrl' i will load the got string (form IdHTTP1.get()), but what
should i use for the second parameter: 'bDeleteRegistry' ? What would be a
useful value for it?
Thanks
asker
> accordingly your good advice with the IDE i installed
> the Microsoft Active Plugin (Version 1.0).
That is not the web browser control, nor is that the specific control I
mentioned (i didn't explitically mention any). The correct control that you
should have imported is "Microsoft Internet Controls" instead. There may be
another one, but its name escapes me at the moment
Gambit
Without your help, i surely would have given up.
So at all events: Thank you very much for this!
...it's a good beginning for more in that direction !!!!
YEEEAAAAAAHHHHHHHHHHHHHHHH *ggg*
(But that will start a little bit later *g*)
asker