Hi Guys!!
This question is the same as the subject. Is there a way to determine the external IP address?
Many Thanks,
Googie.
Determining External IP Address.
Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 8336
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Determining External IP Address.
The easiest way is to put an LC Server script on your server that returns $REMOTE_ADDR.
What will you be doing with it?
What will you be doing with it?
Richard Gaskin
Community volunteer LiveCode Community Liaison
LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
Community volunteer LiveCode Community Liaison
LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
Re: Determining External IP Address.
I have developed a Paper, Rock, Scissors multiplayer game for Android. The client (on Android device) gets an IP address from a website and then connects to that IP address which is the server (Windows).
I wanted to check the external IP address with the saved IP address on the website and if it changes (my IP address changes every 48 hours), update the IP address on the web server via FTP when it changes, so that the website IP address will always be updated.
I'm not sure if I explained it in the best way, lol!
Many Thanks,
Googie.
I wanted to check the external IP address with the saved IP address on the website and if it changes (my IP address changes every 48 hours), update the IP address on the web server via FTP when it changes, so that the website IP address will always be updated.
I'm not sure if I explained it in the best way, lol!
Many Thanks,
Googie.
Re: Determining External IP Address.
Just to get it right:
It's the IP of the "server (Windows)", that your "client (Android)" should retrieve from a "web server (where you have FTP & a site)"?
The easiest way to achieve this to use DynDNS.
Check the router your Win server is behind - most routers have this feature. It works like this: Every time the external router IP changes the router notifies a service of the new number. And the service provides a URL that resolves to this IP.
Such a service (DynDNS) is available in quite same web server packages; there are some free services available, too (search: "free dyndns")
If it's working, you have a URL like "myserver.ddns.com" that always resolves to the current public IP of your "servers (Windows)" router. Add a port forwarding, Bingo.
Or you drop a little php script on the server ("myip.php"?):
This responds with the public IP of whatever calls it. Call it from the "server (Windows)", store the IP somewhere on the web server where the "client (Android)" can find it. Have your port forwarding, Bingo.
For sure, a LC server can do this, too. But it can be a bit cumbersome to set one up ;-)
I'd use DynDNS. Once established it works reliably & requires zero further action.
Have fun!
It's the IP of the "server (Windows)", that your "client (Android)" should retrieve from a "web server (where you have FTP & a site)"?
The easiest way to achieve this to use DynDNS.
Check the router your Win server is behind - most routers have this feature. It works like this: Every time the external router IP changes the router notifies a service of the new number. And the service provides a URL that resolves to this IP.
Such a service (DynDNS) is available in quite same web server packages; there are some free services available, too (search: "free dyndns")
If it's working, you have a URL like "myserver.ddns.com" that always resolves to the current public IP of your "servers (Windows)" router. Add a port forwarding, Bingo.
Or you drop a little php script on the server ("myip.php"?):
Code: Select all
<?PHP
function getUserIP()
{
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = $_SERVER['REMOTE_ADDR'];
if(filter_var($client, FILTER_VALIDATE_IP))
{
$ip = $client;
}
elseif(filter_var($forward, FILTER_VALIDATE_IP))
{
$ip = $forward;
}
else
{
$ip = $remote;
}
return $ip;
}
$user_ip = getUserIP();
echo $user_ip; // Output IP address [Ex: 177.87.193.134]
?>
For sure, a LC server can do this, too. But it can be a bit cumbersome to set one up ;-)
I'd use DynDNS. Once established it works reliably & requires zero further action.
Have fun!
Livecode programming until the cat hits the fan ...