For desktop app, how do you get IP address

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm

For desktop app, how do you get IP address

Post by shawnblc »

I'm been trying to find this in the dictionary or a sample, but not having much luck.
I see hostAddressToName in the dictionary. Perhaps someone can point me somewhere. Thanks.
Last edited by shawnblc on Fri Feb 28, 2014 11:51 pm, edited 1 time in total.
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3582
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: For desktop add, how to get IP address

Post by mwieder »

yeah, this question comes up every now and then, and the answer depends a lot on what you're trying to do. Are you behind a router in a subnet? Do you want the local ip address or a public ip address?
shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm

Re: For desktop add, how to get IP address

Post by shawnblc »

mwieder wrote:yeah, this question comes up every now and then, and the answer depends a lot on what you're trying to do. Are you behind a router in a subnet? Do you want the local ip address or a public ip address?

For my desktop app I want to log the ip address of the user using it. There will eventually be a windows version and a osx version.

For example I'd like this information logged:

$_SERVER['HTTP_X_FORWARDED_FOR']
$_SERVER['REMOTE_ADDR']
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3582
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: For desktop add, how to get IP address

Post by mwieder »

So... forgive me for being a bit confused here...

1 You've got a server app running and you'd like to log the remote user's ip address?
or
2. You're running a desktop app and for some reason want to log the user's ip address locally?
shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm

Re: For desktop add, how to get IP address

Post by shawnblc »

mwieder wrote:So... forgive me for being a bit confused here...

1 You've got a server app running and you'd like to log the remote user's ip address?
or
2. You're running a desktop app and for some reason want to log the user's ip address locally?
It's a local desktop app, but I'd like to be able to log the users IP address. So when they first start the app up it'll log it to a database.

This can be done with php, but since I'm using lc I'd rather do it all within lc.
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3582
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: For desktop app, how do you get IP address

Post by mwieder »

OK. So do you want the user's public-facing ip address or their local address (assuming a router is in place)? Or do you care which?
shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm

Re: For desktop app, how do you get IP address

Post by shawnblc »

mwieder wrote:OK. So do you want the user's public-facing ip address or their local address (assuming a router is in place)? Or do you care which?
The public.
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3582
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: For desktop app, how do you get IP address

Post by mwieder »

In that case, let me point you to http://forums.runrev.com/viewtopic.php? ... ame#p75403 which should give you what you need.
shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm

Re: For desktop app, how do you get IP address

Post by shawnblc »

mwieder wrote:In that case, let me point you to http://forums.runrev.com/viewtopic.php? ... ame#p75403 which should give you what you need.

Between that and a little php coding I'll get exactly what I need. Thank you sir.

Code: Select all

on mouseUp
   answer the hostNameToAddress of the hostName
end mouseUp

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3582
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: For desktop app, how do you get IP address

Post by mwieder »

answer the hostNameToAddress of the hostName
That will give you the local ip address, not the public one.
shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm

Re: For desktop app, how do you get IP address

Post by shawnblc »

mwieder wrote:
answer the hostNameToAddress of the hostName
That will give you the local ip address, not the public one.
Just attached it to a button and I see that. I see they were also querying a url for the public ip in that thread. Thanks. You helped me though.
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3582
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: For desktop app, how do you get IP address

Post by mwieder »

Yeah, the external url is a good way to get the public ip address.
Glad it helped.
Post Reply