Export (0) Print
Expand All

IPAddress.ScopeId Property

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Gets or sets the IPv6 address scope identifier.

[Visual Basic]
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);

Property Value

A long integer specifying the scope of the address.

Exceptions

Exception Type Condition
SocketException AddressFamily = InterNetwork.
ArgumentOutOfRangeException ScopeId is less than 0.

-or-

ScopeId is greater than 0x00000000FFFFFFFF.

Remarks

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.
Note   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.
Note   Site-local addresses, identified by the Format Prefix (FP) FEC0, are used by nodes when communicating on private intranets.

The notation that is used to specify the ScopeId with an address is Address%ScopeId. For example, FE80::5EFE:192.168.41.30%2 .

Example

[Visual Basic] 
' 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] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

IPAddress Class | IPAddress Members | System.Net Namespace

Show:
© 2014 Microsoft