語言

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。

範圍識別碼為 < 0

-或-

範圍識別碼為 > 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: " + 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 意義會依使用情境而異。

  • 連結-本地地址。 在多個介面連接到不同連結的主機上,同一個連結本地位址可以分配給多個介面。 為了消除這種歧義,使用作用域識別碼來指定訊息交換的介面。

Note

連結本地位址以格式前綴(Format Prefix (FP)FE80 標示,供節點在與同一連結上鄰近節點通訊時使用。

  • 地點與本地的地址。 主機可以連接多個站點。 此時,範圍識別碼用來指示要通訊的特定站點。

Note

節點在私有內聯網通訊時使用由格式前綴(FP)FEC0 識別的站點本地位址。

用來指定 ScopeId 帶有位址的符號為 Address%ScopeId。 例如, FE80::5EFE:192.168.41.30%2.

適用於