IPv6網絡開發范例
2008-04-14 12:57
148 查看
*.下载:微软IPv6技术白皮书
*.下述代码是列出所有的单播IPv6地址.
private void DisplayAllAddresses()
{
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
int i=0;
foreach (NetworkInterface adapter in adapters)
{
IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
UnicastIPAddressInformationCollection allAddress =
adapterProperties.UnicastAddresses;
if (allAddress.Count > 0)
{
textBox2.Text += "interface "+i+ "description:\n\t "+adapter.Description+ "\n ";
i++;
foreach (UnicastIPAddressInformation addr in allAddress)
{
if (addr.Address.AddressFamily ==AddressFamily.InterNetworkV6)
ipListComb.Items.Add(addr.Address);
}
}
}
}
*.判断输入的字符串是否是合法的IPV6 地址
public static bool IsIPV6(string input)
{
string pattern = "";
string temp = input;
string[] strs = temp.Split(':');
if(strs.Length > 8)
{
return false;
}
int count = MetarnetRegex.GetStringCount(input,"::");
if(count>1)
{
return false;
}
else if(count == 0)
{
pattern = @"^([\da-f]{1,4}:){7}[\da-f]{1,4}$";
Regex regex = new Regex(pattern);
return regex.IsMatch(input);
}
else
{
pattern = @"^([\da-f]{1,4}:){0,5}::([\da-f]{1,4}:){0,5}[\da-f]{1,4}$";
Regex regex1 = new Regex(pattern);
return regex1.IsMatch(input);
}
}
*.下述代码是列出所有的单播IPv6地址.
private void DisplayAllAddresses()
{
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
int i=0;
foreach (NetworkInterface adapter in adapters)
{
IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
UnicastIPAddressInformationCollection allAddress =
adapterProperties.UnicastAddresses;
if (allAddress.Count > 0)
{
textBox2.Text += "interface "+i+ "description:\n\t "+adapter.Description+ "\n ";
i++;
foreach (UnicastIPAddressInformation addr in allAddress)
{
if (addr.Address.AddressFamily ==AddressFamily.InterNetworkV6)
ipListComb.Items.Add(addr.Address);
}
}
}
}
*.判断输入的字符串是否是合法的IPV6 地址
public static bool IsIPV6(string input)
{
string pattern = "";
string temp = input;
string[] strs = temp.Split(':');
if(strs.Length > 8)
{
return false;
}
int count = MetarnetRegex.GetStringCount(input,"::");
if(count>1)
{
return false;
}
else if(count == 0)
{
pattern = @"^([\da-f]{1,4}:){7}[\da-f]{1,4}$";
Regex regex = new Regex(pattern);
return regex.IsMatch(input);
}
else
{
pattern = @"^([\da-f]{1,4}:){0,5}::([\da-f]{1,4}:){0,5}[\da-f]{1,4}$";
Regex regex1 = new Regex(pattern);
return regex1.IsMatch(input);
}
}
相关文章推荐
- ipv4 ipv6 原理与如何使用
- 第五章 大网高级(一) IPv6
- app store ipv6 被拒 本地ipv6测试环境搭建
- nginx开启IPV6支持配置
- CentOS6.5(1)----设置静态IP并禁用IPV6
- gogodroid--android 上的IPV6工具
- 检查服务器是否支持ipv6
- 2017重新出发:IPv6终于启用啦!
- IPv6 Cocos2d-x
- IPv6 中文RFC 汇总
- centos 7禁用ipv6
- ipv6的表示方法
- 阿里云通过He.net添加IPV6支持(本文对应的服务器操作系统为CentOS)
- ipv6与oracle database
- smtp邮件服务 ipv6 高级网络配置
- Socket之iOS项目中的socket应用/IPV6 转换/域名转IP/解析socket接受的数据/心跳包
- 查看网站使用ipv4还是ipv6网络连接
- iOS----------如何检查域名是否支持ipv6
- iOS应用支持IPV6,就那点事儿
- 为何要支持IPV6