ISP Ip Address - How get In Clarion

Hi,

I want to find the ip address of my Internet Provider. How can I do this in Clarion?

Thanks

1 Like

Would something like this work?

https://www.ipify.org/

This SO question has a bunch of other possabilities:

1 Like

Have a look at

http://sqlkey.com/non-sql-tips/finding-your-external-ip-in-cw/

This is one way that worked for me.

2 Likes

Litreum.com contains clarionfoundry’s FAQ.
This link might take you right there -
http://www.litreum.com/Articles?articleId=7852
if it doesn’t just navigate the tree to Clarionfoundry/communications/ftp/Winsock Woes - Getting IP Address

James, all

I took a look at the COL example (TCP/IP name and address resolution) and it is returning the local IP.

So is there any way to get the public IP (that comes from ISP)?

Maybe try scraping the https://whatsmyip.com/ home page? They have an API, but a cursory look seems as if not what you want.

Regardless of Clarion, there is now way your local machine inside NAT would know the public IPv4 address of your internet gateway (unless it’s set up on a public IP which in rather unlikely). You can only obtain your local machine private IP with Windows API.

Note that your public IP inside NAT may be different depending on the route you take to different networks. It may also change as some routers have a feature of load balancing between 2 internet connections from different providers. Therefore each time you connect to the web your public ip may be different.

However in most cases you would have just one provider or BGP which would have the same IP regardless of the route. Still, you would need something external to tell you which IP you use to connect to it.

Have a look here https://whoami.yait.blog/ - the code behind it is simple
index.php

<?php
$IP =$_SERVER['REMOTE_ADDR'];
$myname= gethostbyaddr($_SERVER['REMOTE_ADDR']);
$country = geoip_country_name_by_name($myname);
$revip = gethostbyname($myname) ;
echo "Your IP: ".$IP."  reverse DNS name is: ".$mynname." country ".$country." " ;
if ( $IP == $revip ):
        echo "your rev DNS name matches" ;
else:
        echo "rev DNS name mismatch" ;
endif;
echo "\n" ;
?>

To get just an IP just put this on any php enabled web server
EDIT! It must be outside your local network, but you can rent one for a few dollars a year, there are millions of providers of such a service. You can have this on your website in a subfolder or subdomain.

<?php
$IP =$_SERVER['REMOTE_ADDR'];
echo $IP;
?>

and then capture http response using NetTalk NetTalk Documentation Index or or LibCurl for Clarion GitHub - mikeduglas/libcurl: libcurl for Clarion or native Clarion HttpWebRequest (never used that one, but there seems to be an example in Examples\ClaTalk\HttpRequest according to the help file).

1 Like