views:

24

answers:

1

I'm building an app in Adobe Air 2 with AS3 and need to get the users ip address. From what I understand this code should work but is tracing: "::1" not an ip. Thank you.

var netInterfaces = NetworkInfo.networkInfo.findInterfaces();

var addresses = netInterfaces[0].addresses;

var userIp = addresses[0].address;

trace(userIp);
A: 

The code you wrote actually returns the ip adress of the first network Interface it finds. This is in your case the so called loopback device which is used for local connections

with IP4 the ip adress would be 127.0.0.1

with IP6 the ip-adress is ::1

Nikolaus Gradwohl
shoot, how can I accomplish this then?? (and am I the only when that IPv6 confuses the crap out of)
Patrick Gates
depends on what you want to achieve, if you want to know the address the air app uses to connect to your server, try to get it on the server side, if you want every adresse but the localhost ones check the netInterfaces.name property, if you want only ip4 adresses filter the adresses from the address-array by type.
Nikolaus Gradwohl