예제 #1
0
 public IPLocation getCopy()
 {
     IPLocation ret = new IPLocation();
     ret.country = country;
     ret.area = area;
     return ret;
 }
예제 #2
0
        ///<summary>
        ///搜索IP地址搜索
        ///</summary>
        ///<param name="ip"></param>
        ///<returns></returns>
        public IPLocation SearchIPLocation(string ip)
        {
            //将字符IP转换为字节
            string[] ipSp = ip.Split('.');
            if (ipSp.Length != 4)
            {
                throw new ArgumentOutOfRangeException("不是合法的IP地址!");
            }
            byte[] IP = new byte[4];
            for (int i = 0; i < IP.Length; i++)
            {
                IP[i] = (byte)(Int32.Parse(ipSp[i]) & 0xFF);
            }

            IPLocation local  = null;
            long       offset = locateIP(IP);

            if (offset != -1)
            {
                local = getIPLocation(offset);
            }

            if (local == null)
            {
                local         = new IPLocation();
                local.area    = unArea;
                local.country = unCountry;
            }
            return(local);
        }
예제 #3
0
        public IPLocation getCopy()
        {
            IPLocation ret = new IPLocation();

            ret.country = country;
            ret.area    = area;
            return(ret);
        }
예제 #4
0
 ///<summary>
 ///构造函数
 ///</summary>
 ///<param name="ipfile">IP数据库文件绝对路径</param>
 public QQWry(string ipfile)
 {
     buf = new byte[100];
     b3  = new byte[3];
     b4  = new byte[4];
     try
     {
         ipFile = new FileStream(ipfile, FileMode.Open);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     ipBegin = readLong4(0);
     ipEnd   = readLong4(4);
     loc     = new IPLocation();
 }
예제 #5
0
        ///<summary> 
        ///搜索IP地址搜索 
        ///</summary> 
        ///<param name="ip"></param> 
        ///<returns></returns> 
        public IPLocation SearchIPLocation(string ip)
        {
            //将字符IP转换为字节
            string[] ipSp = ip.Split('.');
            if (ipSp.Length != 4)
            {
                throw new ArgumentOutOfRangeException("不是合法的IP地址!");
            }
            byte[] IP = new byte[4];
            for (int i = 0; i < IP.Length; i++)
            {
                IP[i] = (byte) (Int32.Parse(ipSp[i]) & 0xFF);
            }

            IPLocation local = null;
            long offset = locateIP(IP);

            if (offset != -1)
            {
                local = getIPLocation(offset);
            }

            if (local == null)
            {
                local = new IPLocation();
                local.area = unArea;
                local.country = unCountry;
            }
            return local;
        }
예제 #6
0
 ///<summary> 
 ///构造函数 
 ///</summary> 
 ///<param name="ipfile">IP数据库文件绝对路径</param> 
 public QQWry(string ipfile)
 {
     buf = new byte[100];
     b3 = new byte[3];
     b4 = new byte[4];
     try
     {
         ipFile = new FileStream(ipfile, FileMode.Open);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     ipBegin = readLong4(0);
     ipEnd = readLong4(4);
     loc = new IPLocation();
 }