Recent

Author Topic: Indy 10 socket error 11001 Host not found  (Read 1933 times)

teriyaki

  • New Member
  • *
  • Posts: 47
Indy 10 socket error 11001 Host not found
« on: October 20, 2021, 05:24:11 am »
I install Indy10 and try to get the content of url using indy idhttp

Code: Pascal  [Select][+][-]
  1. var
  2.   get_url: string;
  3.   resp: TMemoryStream;
  4. begin
  5.   get_url := 'http://www.yahoo.com';//edit2.Text;
  6.   resp := TMemoryStream.Create;
  7.   try
  8.     IdHTTP1.Get(get_url+'v', resp);
  9.     resp.Position := 0; // <-- add this!!
  10.     memo1.Lines.LoadFromStream(resp);
  11.   finally
  12.     resp.Free;
  13.   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

  • Hero Member
  • *****
  • Posts: 3112
Re: Indy 10 socket error 11001 Host not found
« Reply #1 on: October 20, 2021, 08:00:32 am »
get_url+'v'?

dsiders

  • Hero Member
  • *****
  • Posts: 1045
Re: Indy 10 socket error 11001 Host not found
« Reply #2 on: October 20, 2021, 03:43:47 pm »
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1311
    • Lebeau Software
Re: Indy 10 socket error 11001 Host not found
« Reply #3 on: October 20, 2021, 08:20:15 pm »
Code: Pascal  [Select][+][-]
  1. IdHTTP1.Get(get_url+'v', resp);

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.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

 

TinyPortal © 2005-2018