Forum > Networking and Web Programming

Indy 10 socket error 11001 Host not found

(1/1)

teriyaki:
I install Indy10 and try to get the content of url using indy idhttp


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var  get_url: string;  resp: TMemoryStream;begin  get_url := 'http://www.yahoo.com';//edit2.Text;  resp := TMemoryStream.Create;  try    IdHTTP1.Get(get_url+'v', resp);    resp.Position := 0; // <-- add this!!    memo1.Lines.LoadFromStream(resp);  finally    resp.Free;  end;
but it always reports error

socket error 11001 Host not found

I even enable the inbound/outbound right of my app in windows defender firewall.

but the error has not change


your comment welcome

engkin:
get_url+'v'?

dsiders:

--- Quote from: engkin on October 20, 2021, 08:00:32 am ---get_url+'v'?

--- End quote ---

GIGO

Remy Lebeau:

--- Quote from: teriyaki on October 20, 2021, 05:24:11 am ---
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---IdHTTP1.Get(get_url+'v', resp);
--- End quote ---

Why are you appending 'v' to the URL?  You are asking TIdHTTP to retrieve the URL 'http://www.yahoo.comv', and obviously the hostname 'www.yahoo.comv' does not exist, hence the error.

Also, note that http://www.yahoo.com redirects https://www.yahoo.com, so you need to have an SSLIOHandler component assigned to the TIdHTTP.IOHandler property, such as TIdSSLIOHandlerSocketOpenSSL.  Which TIdHTTP can handle for you, provided you have a suitable SSLIOHandler unit in your uses clause.

Navigation

[0] Message Index

Go to full version