js将ip地址转换成整数

来源:互联网 发布:合肥达内java在哪 编辑:程序博客网 时间:2024/04/29 15:19

//++++++++++++add the judge about ip which the user input++++++++++++++++++//
function judge_ip(){

   
        startip=document.all.txt_startip.value
        endip=document.all.txt_endip.value
        alert('startip');
        exit;
    //ipaddress to nint
        IPAddress ip = IPAddress.Parse(startip);
        Byte[] bytes = ip.GetAddressBytes();
        uint start=bytes[0];
        start = (s << 8) | ((uint)bytes[1]);
        start = (s << 8) | ((uint)bytes[2]);
        start = (s << 8) | ((uint)bytes[3]);
        start_ip = start;
      
        IPAddress ip = IPAddress.Parse(endip);
        Byte[] bytes = ip.GetAddressBytes();
        uint end=bytes[0];
        end = (end << 8) | ((uint)bytes[1]);
        end = (end << 8) | ((uint)bytes[2]);
        end = (end << 8) | ((uint)bytes[3]);
        end_ip = end;
       
        if(end_ip>start_ip+65535){
        alert('<{$lang_err_judge_ip}><{$lang_error_ip}>');
        return false;
        }
}
//++++++++++++add the judge about ip which the user input++++++++++++++++++//

笔记,今日工作中遇到的!

原创粉丝点击