IPAddress.ScopeId 屬性

定義

取得或設定 IPv6 位址範圍識別項。Gets or sets the IPv6 address scope identifier.

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

屬性值

指定位址範圍的長整數。A long integer that specifies the scope of the address.

例外狀況

AddressFamily = InterNetwork.AddressFamily = InterNetwork.

scopeId< 0scopeId < 0 -或--or- scopeId > 0x00000000FFFFFFFFscopeId > 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 的意義會根據其使用的內容而變更。The meaning of ScopeId changes depending on the context in which it is used.

  • 連結-本機位址。Link-local address. 在多個介面連接到不同連結的主機上,可以將相同的連結-本機位址指派給多個介面。On a host with multiple interfaces connected to separate links, the same link-local address can be assigned to multiple interfaces. 若要消除這種不明確的情況,您可以使用範圍識別碼來指定要交換訊息的介面。To eliminate this ambiguity, a scope identifier is used to specify the interface over which messages are exchanged.

注意

連結-在與相同連結上的相鄰節點通訊時,節點會使用格式前置詞(FP) FE80 所識別的連結本機位址。Link-local addresses, identified by the Format Prefix (FP) FE80, are used by nodes when communicating with neighboring nodes on the same link.

  • 網站-本機位址。Site-local addresses. 主機可以連接到多個網站。A host can be connected to multiple sites. 在此情況下,範圍識別碼是用來表示要與之通訊的特定網站。In this case, a scope identifier is used to indicate a specific site to communicate with.

注意

在私人內部網路上通訊時,節點會使用由格式前置詞(FP) FEC0 所識別的網站-本機位址。Site-local addresses, identified by the Format Prefix (FP) FEC0, are used by nodes when communicating on private intranets.

用來指定包含位址之 ScopeId 的標記法為 Address%ScopeIdThe notation that is used to specify the ScopeId with an address is Address%ScopeId. 例如:FE80::5EFE:192.168.41.30%2.For example, FE80::5EFE:192.168.41.30%2.

適用於