ActionScript2011.05.09 14:25
랜카드에 할당된 IP 알아내기 함수

import flash.net.InterfaceAddress;
import flash.net.NetworkInterface;

private var _ip:String = "127.0.0.1";
private var ipPattern:RegExp = /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/;

private function getLanCardIp():void {
    var interfaces:Vector.<NetworkInterface> = new Vector.<NetworkInterface>();
    interfaces = NetworkInfo.networkInfo.findInterfaces();
    
    var ipCheck:int = -1;

    for each (var netf:NetworkInterface in interfaces) {
        var addresses:Vector.<InterfaceAddress> = netf.addresses;
        for each (var interfaceAddress:InterfaceAddress in addresses) {
            ipCheck = interfaceAddress.address.search(ipPattern);
            if (ipCheck == 0) {
                if (interfaceAddress.address.indexOf("169.254.") != 0 && interfaceAddress.address.indexOf("127.0") != 0) {
                    _ip = interfaceAddress.address;
                    break;
                }
            }
        }
    }
}


신고

'ActionScript' 카테고리의 다른 글

웹서버  (0) 2011.05.11
자신의 IP 외부에서 알아오기  (0) 2011.05.09
랜카드에 할당된 IP 알아내기  (0) 2011.05.09
자동 업데이트  (0) 2011.05.09
AIR의 OS별 File.applicationStorageDirectory Paths  (0) 2011.03.15
DockIcon Click 이벤트 처리  (0) 2011.03.04
Posted by sanghwa

티스토리 툴바