IPAddress.ScopeId 属性

定义

获取或设置 IPv6 地址范围标识符。

public:
 property long ScopeId { long get(); void set(long value); };
public long ScopeId { get; set; }
member this.ScopeId : int64 with get, set
Public Property ScopeId As Long

属性值

指定地址范围的长整数。

例外

AddressFamily = InterNetwork.

scopeId< 0

-或-

scopeId> 0x00000000FFFFFFFF

示例

// Display the type of address family supported by the server. If the
// server is IPv6-enabled this value is: InterNetworkV6. If the server
// is also IPv4-enabled there will be an additional value of InterNetwork.
Console::WriteLine( "AddressFamily: {0}", curAdd->AddressFamily );

// Display the ScopeId property in case of IPV6 addresses.
if ( curAdd->AddressFamily.ToString() == ProtocolFamily::InterNetworkV6.ToString() )
         Console::WriteLine( "Scope Id: {0}", curAdd->ScopeId );

// Display the type of address family supported by the server. If the
// server is IPv6-enabled this value is: InterNetworkV6. If the server
// is also IPv4-enabled there will be an additional value of InterNetwork.
Console.WriteLine("AddressFamily: " + curAdd.AddressFamily.ToString());

// Display the ScopeId property in case of IPV6 addresses.
if(curAdd.AddressFamily.ToString() == ProtocolFamily.InterNetworkV6.ToString())
  Console.WriteLine("Scope Id: " + curAdd.ScopeId.ToString());
' Display the type of address family supported by the server. If the
' server is IPv6-enabled this value is: InterNetworkV6. If the server
' is also IPv4-enabled there will be an additional value of InterNetwork.
Console.WriteLine(("AddressFamily: " + curAdd.AddressFamily.ToString()))

' Display the ScopeId property in case of IPV6 addresses.
If curAdd.AddressFamily.ToString() = ProtocolFamily.InterNetworkV6.ToString() Then
  Console.WriteLine(("Scope Id: " + curAdd.ScopeId.ToString()))
End If

注解

根据使用上下文更改的含义 ScopeId

  • 链接本地地址。 在多个接口连接到单独链接的主机上,可以将相同的链接本地地址分配给多个接口。 为了消除这种歧义,使用范围标识符来指定交换消息的接口。

注意

链接本地地址(由格式前缀 (FP) FE80 标识)在与同一链接上的相邻节点通信时由节点使用。

  • 站点本地地址。 主机可以连接到多个站点。 在这种情况下,范围标识符用于指示要与之通信的特定站点。

注意

站点本地地址(由格式前缀 (FP) FEC0 标识)在专用 Intranet 上通信时由节点使用。

用于指定 ScopeId 具有地址的 表示法是 Address%ScopeId。 例如 FE80::5EFE:192.168.41.30%2.

适用于