Note Using this API is not recommended, use the INetworkListManager::GetConnectivity method instead.
The problem is: I do not understand the details.What you not understand, do it like link provided and you have a proper response.
I do not want to understand itThat is the worst a programmer can say, Pascal ain't a script language where you just copy/paste.
Pascal ain't a script language where you just copy/paste.
The only thing I need, is a result only true, if there is a connection.
Do you think, you can just copy me the correct line form there?
The only thing I need, is a result only true, if there is a connection.
"ping"Pings are dropped by any sane servers.... Bad advice.
So you can only say, you have a connection to a server in internet and this mean you have internet. You can start a request to google or your own homepage or a ping to a known server (as Curt say) or read a ntp for time,...
So its your choice to say: I have internet, because xxx work.
Unfortunately I do not know, how to send a ping by Lazarus and how to grab its results.
Please do stop with advising ping as a reliable solution. Really, most servers drop ping requests.
Simply try to connect to example.com which is IANA itself.
The "anti-pingites" raise an interesting question: how would one go about finding out a rough measure of the number of the world's servers that refuse pings? And if it is a regional thing? Same for ntp. Is it a big number? I have no idea.
Google's famous server 8.8.8.8 always responds to ping requests 24/7.
I don't know why ping is so frown on.
The problem is, its existence is not guaranteed in any way.
The problem is, to paraphrase Lewis Carroll, that existence in general is not guaranteed in any way :)Indeed the existence problem is not specific to the internet (unfortunately ;) )
ping 4.2.2.1; // no idea, how to send
What to change?With my demo you do not need Ping or Indy or Ssl or admin rights to execute or whatever else bad reasons exists to not use Ping.
@KodeZwerg:That makes sense :D
I believe the remark you quoted from TS was addressed at the wrong person, hence your confusion ?
It seems to me the project from paweld in post #16 (https://forum.lazarus.freepascal.org/index.php/topic,62144.msg469793.html#msg469793) uses indy.
Do you know if this can fail in case of proxy misconfiguration?I do use InternetOpen (https://learn.microsoft.com/en-us/windows/win32/api/wininet/nf-wininet-internetopenw) with INTERNET_OPEN_TYPE_PRECONFIG flag.
Retrieves the proxy or direct configuration from the registry.I guess when your computer has a corrupt configuration that it fail but I never tested it under such condition (!!)
Here is a list of servers I would prefer to contact, but I do not know how. http://4.2.2.1 does not work.
https://sebastianhetzel.net/zuverlaessige-oeffentliche-dns-server/
Here is a list of servers I would prefer to contact, but I do not know how. http://4.2.2.1 does not work.
https://sebastianhetzel.net/zuverlaessige-oeffentliche-dns-server/
I don't have any Windows setup to test on, I tested on Linux. I'm not sure on Windows, I had to use baseunix for the TTimeVal type definition to set a decent connection timeout.
With a small modification your code works on windows too. Here is a cross platform version, tested on Win10/Linux Mint 20.02, both 64 bit:I don't have any Windows setup to test on, I tested on Linux. I'm not sure on Windows, I had to use baseunix for the TTimeVal type definition to set a decent connection timeout.
On Windows it is likely winsock or winsock2 that is needed for TTimeVal.