次の方法で共有


IPAddress.ScopeId プロパティ

メモ : この名前空間、クラス、およびメンバは、.NET Framework Version 1.1 だけでサポートされています。

IPv6 アドレスのスコープ識別子を取得または設定します。

Public Property ScopeId As Long
[C#]
public long ScopeId {get; set;}
[C++]
public: __property __int64 get_ScopeId();public: __property void set_ScopeId(__int64);
[JScript]
public function get ScopeId() : long;public function set ScopeId(long);

プロパティ値

アドレスのスコープを指定する長整数。

例外

例外の種類 条件
SocketException AddressFamily = InterNetwork.
ArgumentOutOfRangeException ScopeId が 0 未満です。

または

ScopeId が 0x00000000FFFFFFFF より大きい値です。

解説

ScopeId の意味は、それが使用されているコンテキストによって異なります。

  • リンクローカル アドレスの場合。異なるリンクに接続している複数のインターフェイスを持つホストで、同じリンクローカル アドレスを複数のインターフェイスに割り当てることができます。このあいまいさを避けるために、スコープ識別子を使用して、メッセージの交換に使用するインターフェイスを指定します。

メモ   Format Prefix (FP) FE80 によって識別されるリンクローカル アドレスは、同じリンク上の近隣のノードと通信するときにノードによって使用されます。

  • サイトローカル アドレスの場合。複数のサイトにホストが接続できます。この場合、スコープ識別子は通信先の特定のサイトを示すときに使用します。

メモ   Format Prefix (FP) FEC0 によって識別されるサイトローカル アドレスは、プライベート イントラネット上で通信するときにノードによって使用されます。

ScopeId とアドレスを指定するときに使用する表記は Address%ScopeId です。たとえば、 FE80::5EFE:192.168.41.30%2 . です。

使用例

 
' Display the type of address family supported by the server. If the
' server is IPv6-enabled this value is: InternNetworkV6. 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

[C#] 

          // Display the type of address family supported by the server. If the
          // server is IPv6-enabled this value is: InternNetworkV6. 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());


[C++] 

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

IPAddress クラス | IPAddress メンバ | System.Net 名前空間