URL: http://lite.ip2location.com/

Use the code below to convert the IP address of your web visitors and lookup for their geographical location, e.g. country, state, city, latitude/longitude, ZIPs, timezone and so on. Free database can be downloaded at http://lite.ip2location.com.

Expand | Embed | Plain Text
  1. /// <summary>
  2. /// Convert IPV6 Address to IP Number
  3. /// Free geolocation database can be downloaded at:
  4. /// http://lite.ip2location.com/
  5. /// </summary>
  6.  
  7. string strIP = "2404:6800:4001:805::1006";
  8. System.Net.IPAddress address;
  9. System.Numerics.BigInteger ipnum;
  10.  
  11. if (System.Net.IPAddress.TryParse(strIP, out address)) {
  12. byte[] addrBytes = address.GetAddressBytes();
  13.  
  14. if (System.BitConverter.IsLittleEndian) {
  15. System.Collections.Generic.List<byte> byteList = new System.Collections.Generic.List<byte>(addrBytes);
  16. byteList.Reverse();
  17. addrBytes = byteList.ToArray();
  18. }
  19.  
  20. if (addrBytes.Length > 8) {
  21. //IPv6
  22. ipnum = System.BitConverter.ToUInt64(addrBytes, 8);
  23. ipnum <<= 64;
  24. ipnum += System.BitConverter.ToUInt64(addrBytes, 0);
  25. } else {
  26. //IPv4
  27. ipnum = System.BitConverter.ToUInt32(addrBytes, 0);
  28. }
  29. }

Convert IPv6 Address to IP numbers (C#)的更多相关文章

  1. [LeetCode] Validate IP Address 验证IP地址

    In this problem, your job to write a function to check whether a input string is a valid IPv4 addres ...

  2. IPv6 tutorial 4 IPv6 address syntax

    https://4sysops.com/archives/ipv6-tutorial-part-4-ipv6-address-syntax/ Now that you know about the n ...

  3. How to support both ipv4 and ipv6 address for JAVA code.

    IPv6 have colon character, for example FF:00::EEIf concatenate URL String, IPv6 URL will like: http: ...

  4. 2019牛客多校第六场 B - Shorten IPv6 Address 模拟

    B - Shorten IPv6 Address 题意 给你\(128\)位的二进制,转换为十六进制. 每\(4\)位十六进制分为\(1\)组,每两组用一个\(":"\)分开. 每 ...

  5. 华东师大OJ:IP Address【IP地址转换】

    /*===================================== IP Address Time Limit:1000MS Memory Limit:30000KB Total Subm ...

  6. [LintCode] Restore IP Address 复原IP地址

    Given a string containing only digits, restore it by returning all possible valid IP address combina ...

  7. [Leetcode] restore ip address 存储IP地址

    Given a string containing only digits, restore it by returning all possible valid IP address combina ...

  8. 468 Validate IP Address 验证IP地址

    详见:https://leetcode.com/problems/validate-ip-address/description/ Java实现: class Solution { public St ...

  9. 牛客多校第六场 B Shorten IPv6 Address 模拟

    题意: 给你一个二进制表示的IPv6地址,让你把它转换成8组4位的16进制,用冒号分组的表示法.单组的前导0可以省略,连续多组为0的可以用两个冒号替换,但是只允许替换一次.把这个地址通过这几种省略方式 ...

随机推荐

  1. [linux]树莓派入手体验和系统安装

    背景 一直想捣鼓点什么东西.当看到树莓派的时候,就是它了. 树莓派可以安装Linux系统,而我在工作当中,可以说Linux是一半工作环境.树莓派真是个好东西,这个东西应该在我学习linxu/Unix的 ...

  2. NET Framework 4.0的安装失败处理

    如果是XP系统,这么做:1.开始——运行——输入cmd——回车——在打开的窗口中输入net stop WuAuServ2.开始——运行——输入%windir%3.在打开的窗口中有个文件夹叫Softwa ...

  3. discuz数据库表

    http://faq.comsenz.com/library/database/x3/x3_index.htm    discuz数据库表字典 Discuz X3各数据库表用途 pre_common_ ...

  4. Ubuntu12.04配置mod_python

    安装: sudo apt-get install libapache2-mod-python python-mysqldb 然后编辑配置文件/etc/apache2/sites-enabled/000 ...

  5. mac 下真机调试 android 手机

    第一步: 查看usb设备信息 在 终端输入:system_profiler SPUSBDataType     可以查看连接的usb设备的信息 比如我的usb信息如下(部分内容): Spreadtru ...

  6. Web大文件下载控件更新-Xproer.HttpDownloader

    资源下载:cab安装包(x86),cab安装包(x64),xpi安装包,crx安装包,nat安装包,exe安装包,开发文档,根证书,VC库,   更新时间:2016-08-19 版本号:1,2,56, ...

  7. Pyhton开发堡垒机之paramiko模块

    堡垒机前戏 开发堡垒机之前,先来学习Python的paramiko模块,该模块机遇SSH用于连接远程服务器并执行相关操作 SSHClient 用于连接远程服务器并执行基本命令 基于用户名密码连接: + ...

  8. (原创)即使最可怕的自然力量,也不失美丽——火山喷发(摄影,欣赏)

    文中图片摘自腾讯文化:www.cal.qq.com 1.Abstract     最可怕的力量也潜含着最美丽的风景奇观,虽然不能亲眼目睹,但透过大师的视角,一样也能体会到自然力量撼动的美丽. 2.Co ...

  9. unity3d asset store下载的代码所在位置

    Asset Store下载了官方的示例,却找不到了,又不想重新下载 PC:C:\Users\PCNAME\AppData\Roaming\Unity\Asset StoreMAC:"~/Li ...

  10. js不是从上到下执行的吗?

    如果说js是从上到下解释执行的, 那么,按道理应该会执行错误前面的代码. 如: [代码一] //输出1,2,到3报错 console.log("一") console.log(&q ...