Page 1 of 1

Get Public IP

Posted: Wed Sep 10, 2014 4:25 am
by PedroAlex
Hello Comunity.

For anyone who has experience with work on the net, could give a hint on the best way to get the Public IP in an application xBase..

Thanks in advance.
Pedro

Re: Get Public IP

Posted: Wed Sep 10, 2014 8:34 am
by skiman
Hi,

Something as:
cResult := loadfromurl("http://checkip.dyndns.org/")

cResult will contain the following: Current IP Address: 194.78.56.73

Then you can get the IP:
cMyIp := substr( cResult , at(":",cResult)+2)
or
cMyIp := dc_tokenarray(cResult,":")[2]

Re: Get Public IP

Posted: Wed Sep 10, 2014 10:23 am
by PedroAlex
Hi Cris.
many thanks for feed Back.

LoadFromUrl() works well for me and even better with this link :

Function GetPublicIPAddress()
LOCAL cIP := LoadFromURL('http://ipecho.net/plain')
return cIP

Sounds like a good solution and does not need external Libs

However someone knows a more recent technique?

Thanks..
Pedro