IPAddress.IPv6None 字段
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
提供指示不应使用任何网络接口的 IP 地址。 此属性为只读。
public: static initonly System::Net::IPAddress ^ IPv6None;
public static readonly System.Net.IPAddress IPv6None;
staticval mutable IPv6None : System.Net.IPAddress
Public Shared ReadOnly IPv6None As IPAddress
字段值
示例
下面的代码示例以标准压缩格式显示当前主机的 None 地址的值。
// This method displays the value of the current host's None address in
// standard compressed format. The None address is used by the host to disable
// listening to client activities on all the interfaces.
void displayIPv6NoneAddress()
{
try
{
// Get the None address.
IPAddress^ none = IPAddress::IPv6None;
// Transform the None address to a string using the overloaded
// ToString() method. Note that the resulting string is in the compact
// form: "::".
String^ ipv6None = none->ToString();
Console::WriteLine( "The IPv6 None address is: {0}", ipv6None );
}
catch ( Exception^ e )
{
Console::WriteLine( "->Item[displayIPv6NoneAddress] Exception: {0}", e );
}
}
// This method displays the value of the current host's None address in
// standard compressed format. The None address is used by the host to disable
// listening to client activities on all the interfaces.
private static void displayIPv6NoneAddress()
{
try
{
// Get the None address.
IPAddress none = IPAddress.IPv6None;
// Transform the None address to a string using the overloaded
// ToString() method. Note that the resulting string is in the compact
// form: "::".
string ipv6None = none.ToString();
Console.WriteLine("The IPv6 None address is: " + ipv6None);
}
catch (Exception e)
{
Console.WriteLine("[displayIPv6NoneAddress] Exception: " + e.ToString());
}
}
' This function prints the value of the current host's None address in
' standard compressed format. The None address is used by the host to disable
' listening to client activities on all the interfaces.
Private Shared Sub printIPv6NoneAddress()
Try
' Get the None address.
Dim none As IPAddress = IPAddress.IPv6None
' Transform the None address to a string using the overloaded
' ToString() method. Note that the resulting string is in the compact
' form: "::".
Dim ipv6None As String = none.ToString()
Console.WriteLine(("The IPv6 None address is: " + ipv6None))
Catch e As Exception
Console.WriteLine(("[printIPv6NoneAddress] Exception: " + e.ToString()))
End Try
End Sub
注解
方法 Socket.Bind 使用 IPv6None 字段来指示 Socket 不得侦听客户端活动。 字段 IPv6None 等效于冒号-十六进制表示法中的 0:0:0:0:0:0,或在压缩表示法中等效于 ::0。