package util{ import com.hurlant.crypto.rsa.RSAKey; import com.hurlant.util.Hex; import flash.display.Sprite; import flash.net.InterfaceAddress; import flash.net.NetworkInfo; import flash.net.NetworkInterface; import flash.utils.ByteArray; public class GetAddress extends Sprite { public function GetAddressList():void { var networkInfo:NetworkInfo = NetworkInfo.networkInfo; var interfaces:Vector.<NetworkInterface> = networkInfo.findInterfaces(); if( interfaces != null ) { trace( "Interface count: " + interfaces.length ); for each ( var interfaceObj:NetworkInterface in interfaces ) { trace( "\nname: " + interfaceObj.name ); trace( "display name: " + interfaceObj.displayName ); trace( "mtu: " + interfaceObj.mtu ); trace( "active?: " + interfaceObj.active ); trace( "parent interface: " + interfaceObj.parent ); trace( "hardware address: " + interfaceObj.hardwareAddress ); if( interfaceObj.subInterfaces != null ) { trace( "# subinterfaces: " + interfaceObj.subInterfaces.length ); } trace("# addresses: " + interfaceObj.addresses.length ); for each ( var address:InterfaceAddress in interfaceObj.addresses ) { trace( " type: " + address.ipVersion ); trace( " address: " + address.address ); trace( " broadcast: " + address.broadcast ); trace( " prefix length: " + address.prefixLength ); } } } } }}
===============控制台內容:===============
name: {97ED7215-4BDF-4FF1-AB5C-73AE76E87C87}display name: 無線網路串連 2mtu: 1500active?: falseparent interface: nullhardware address: 78-92-9C-06-65-E3# addresses: 2 type: IPv4 address: 169.254.250.76 broadcast: 169.254.255.255 prefix length: 16 type: IPv4 address: 192.168.23.1 broadcast: 192.168.23.255 prefix length: 24name: {C208B292-1BE4-4ADC-9385-C0A40972E216}display name: 本地串連mtu: 1500active?: falseparent interface: nullhardware address: 5C-26-0A-6F-44-26# addresses: 1 type: IPv4 address: 169.254.225.215 broadcast: 169.254.255.255 prefix length: 16name: {D9CEA236-6DEB-4EE6-8646-45C44AC627C9}display name: 無線網路串連mtu: 1500active?: trueparent interface: nullhardware address: 78-92-9C-06-65-E2# addresses: 1 type: IPv4 address: 192.168.2.102 broadcast: 192.168.2.255 prefix length: 24name: {846EE342-7039-11DE-9D20-806E6F6E6963}display name: Loopback Pseudo-Interface 1mtu: -1active?: trueparent interface: nullhardware address:# addresses: 2 type: IPv6 address: ::1 broadcast: prefix length: 128 type: IPv4 address: 127.0.0.1 broadcast: prefix length: 8name: {C4A6309C-ED0C-406D-B4AB-295B9223EA5D}display name: Teredo Tunneling Pseudo-Interfacemtu: 1280active?: trueparent interface: nullhardware address: 00-00-00-00-00-00-00-E0# addresses: 1 type: IPv6 address: 2001:0:9d38:6abd:200a:3639:3f57:fd99 broadcast: prefix length: 64
本文出自 “程式員的技術部落格” 部落格,請務必保留此出處http://programmer.blog.51cto.com/2859493/1286443