Page 1 of 1
For desktop app, how do you get IP address
Posted: Fri Feb 28, 2014 10:00 pm
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.
Re: For desktop add, how to get IP address
Posted: Fri Feb 28, 2014 10:09 pm
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?
Re: For desktop add, how to get IP address
Posted: Fri Feb 28, 2014 11:21 pm
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']
Re: For desktop add, how to get IP address
Posted: Fri Feb 28, 2014 11:39 pm
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?
Re: For desktop add, how to get IP address
Posted: Fri Feb 28, 2014 11:43 pm
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.
Re: For desktop app, how do you get IP address
Posted: Sat Mar 01, 2014 12:11 am
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?
Re: For desktop app, how do you get IP address
Posted: Sat Mar 01, 2014 12:35 am
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.
Re: For desktop app, how do you get IP address
Posted: Sat Mar 01, 2014 1:01 am
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.
Re: For desktop app, how do you get IP address
Posted: Sat Mar 01, 2014 1:08 am
by shawnblc
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
Re: For desktop app, how do you get IP address
Posted: Sat Mar 01, 2014 1:21 am
by mwieder
answer the hostNameToAddress of the hostName
That will give you the local ip address, not the public one.
Re: For desktop app, how do you get IP address
Posted: Sat Mar 01, 2014 1:33 am
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.
Re: For desktop app, how do you get IP address
Posted: Sat Mar 01, 2014 1:55 am
by mwieder
Yeah, the external url is a good way to get the public ip address.
Glad it helped.