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