Convert IPv6 Address to IP numbers (C#)
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.
- /// <summary>
- /// Convert IPV6 Address to IP Number
- /// Free geolocation database can be downloaded at:
- /// http://lite.ip2location.com/
- /// </summary>
- string strIP = "2404:6800:4001:805::1006";
- System.Net.IPAddress address;
- System.Numerics.BigInteger ipnum;
- if (System.Net.IPAddress.TryParse(strIP, out address)) {
- byte[] addrBytes = address.GetAddressBytes();
- if (System.BitConverter.IsLittleEndian) {
- System.Collections.Generic.List<byte> byteList = new System.Collections.Generic.List<byte>(addrBytes);
- byteList.Reverse();
- addrBytes = byteList.ToArray();
- }
- if (addrBytes.Length > 8) {
- //IPv6
- ipnum = System.BitConverter.ToUInt64(addrBytes, 8);
- ipnum <<= 64;
- ipnum += System.BitConverter.ToUInt64(addrBytes, 0);
- } else {
- //IPv4
- ipnum = System.BitConverter.ToUInt32(addrBytes, 0);
- }
- }
Convert IPv6 Address to IP numbers (C#)的更多相关文章
- [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 ...
- IPv6 tutorial 4 IPv6 address syntax
https://4sysops.com/archives/ipv6-tutorial-part-4-ipv6-address-syntax/ Now that you know about the n ...
- 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: ...
- 2019牛客多校第六场 B - Shorten IPv6 Address 模拟
B - Shorten IPv6 Address 题意 给你\(128\)位的二进制,转换为十六进制. 每\(4\)位十六进制分为\(1\)组,每两组用一个\(":"\)分开. 每 ...
- 华东师大OJ:IP Address【IP地址转换】
/*===================================== IP Address Time Limit:1000MS Memory Limit:30000KB Total Subm ...
- [LintCode] Restore IP Address 复原IP地址
Given a string containing only digits, restore it by returning all possible valid IP address combina ...
- [Leetcode] restore ip address 存储IP地址
Given a string containing only digits, restore it by returning all possible valid IP address combina ...
- 468 Validate IP Address 验证IP地址
详见:https://leetcode.com/problems/validate-ip-address/description/ Java实现: class Solution { public St ...
- 牛客多校第六场 B Shorten IPv6 Address 模拟
题意: 给你一个二进制表示的IPv6地址,让你把它转换成8组4位的16进制,用冒号分组的表示法.单组的前导0可以省略,连续多组为0的可以用两个冒号替换,但是只允许替换一次.把这个地址通过这几种省略方式 ...
随机推荐
- LeetCode(76) Minimum Window Substring
题目 Given a string S and a string T, find the minimum window in S which will contain all the characte ...
- linux sudo命令
Sudo”是Unix/Linux平台上的一个非常有用的工具,它允许系统管理员分配给普通用户一些合理的“权利”,让他们执行一些只有超级用户或其他 特许用户才能完成的任务,比如:运行一些像mount,ha ...
- 1531: [POI2005]Bank notes二进制优化(c++)
Description Byteotian Bit Bank (BBB) 拥有一套先进的货币系统,这个系统一共有n种面值的硬币,面值分别为b1, b2,..., bn. 但是每种硬币有数量限制,现在我 ...
- Jade之Code
Code jade支持内嵌js的代码到jade代码之中. Unbuffered Code 无缓冲代码以-符号开始,无任何额外输出(文本是什么即是什么). jade: - for (var x = 0; ...
- Android Studio项目结构
我们创建了一个Android Project,打开就如下图所示: 我们选择Project视图,就会有以下的项目文档结构: 上面笔者标注的数字是接下来要讲解的内容. 我们先来看1: 我们创建Appl ...
- wamp链接mysql数据库
一:链接到自带的数据库 1.打开mysql命令行 密码为空即回车2.输入use mysql 3.执行 update user set password=PASSWORD('123456') where ...
- MongoDB基本概念
MongoDB是一种强大灵活可扩展的数据存储方式,它扩展了关系数据库的众多功能.MongoDB的功能非常丰富,但是却非常容易上手和便于使用,今天来了解一下MongoDB的主要概念. 文档 文档是的核心 ...
- Dynamic CRM 2013学习笔记(三十二)自定义审批流3 - 节点及实体配置
上次介绍了<Dynamic CRM 2013学习笔记(十九)自定义审批流1 - 效果演示> 以及如何配置自定义审批流的按钮:<Dynamic CRM 2013学习笔记(二十一)自定义 ...
- Dynamic CRM 2013学习笔记(六)备份和恢复
这节我们将讨论下怎么维护CRM,包括以下主要内容: 备份CRM DB 备份CRM 系统 恢复CRM DB 恢复 CRM 系统 一. 备份CRM DB 下面的步骤将为CRM DB创建一个维护计划 ...
- solr与.net系列课程(九)solr5.1的配置
solr与.net系列课程(九)solr5.1的配置 最近一些园友来咨询solr5.1的配置方式,然后我就去官网下载了个最新版本的solr,发现solr5.0以后solr的下载包里的内容发生的变化,移 ...