About the ip check with ipv4 and ipv6
I have a ip check in my source use csharp.
And now, I must to think about the check rule about the ipv4 and ipv6.
The client side maybe like ↓
・only ipv4
・only ipv6
・both ipv4 and ipv6
Im sorry , Im new to the networking .
As so , Is anybody could give me some suggestion about the ip check?
Thanks.
About the IP Check:
I have a check like ↓ now :
bool isgoodip()
{
return ip.startwith(173);
}
If the client side has only the ipv6 , how can I do the check like this ?
and , is there has a server setting can convert the ipv6 to the ipv4 auto ?
Using Statements
using System.Net;
using System.Net.Sockets;
IP Checking Code
IPAddress address = IPAddress.Parse("127.0.0.1");
if (address.AddressFamily == AddressFamily.InterNetwork) // IPv4
{
// do ipv4 stuff here
}
if (address.AddressFamily == AddressFamily.InterNetworkV6) // IPv6
{
// do ipv6 stuff here
}
if ((address.AddressFamily == AddressFamily.InterNetwork) || (address.AddressFamily == AddressFamily.InterNetworkV6)) // IPv4 and IPv6
{
// do both ipv4 and ipv6 stuff here
}
链接地址: http://www.djcxy.com/p/40612.html
上一篇: 如何通过使用Groovy或Java的IPv6访问网站
下一篇: 关于ipv4和ipv6的ip检查