IPInterfaceProperties.AnycastAddresses Vlastnost
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Získá ip adresy anycast přiřazené k tomuto rozhraní.
public:
abstract property System::Net::NetworkInformation::IPAddressInformationCollection ^ AnycastAddresses { System::Net::NetworkInformation::IPAddressInformationCollection ^ get(); };
public abstract System.Net.NetworkInformation.IPAddressInformationCollection AnycastAddresses { get; }
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public abstract System.Net.NetworkInformation.IPAddressInformationCollection AnycastAddresses { get; }
member this.AnycastAddresses : System.Net.NetworkInformation.IPAddressInformationCollection
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
member this.AnycastAddresses : System.Net.NetworkInformation.IPAddressInformationCollection
Public MustOverride ReadOnly Property AnycastAddresses As IPAddressInformationCollection
Hodnota vlastnosti
Obsahuje IPAddressInformationCollection adresy anycast pro toto rozhraní.
- Atributy
Příklady
Následující příklad kódu zobrazí adresy anycast pro síťová rozhraní v místním počítači.
void DisplayAnycastAddresses()
{
int count = 0;
Console::WriteLine( "Anycast Addresses" );
array<NetworkInterface^>^adapters = NetworkInterface::GetAllNetworkInterfaces();
System::Collections::IEnumerator^ myEnum13 = adapters->GetEnumerator();
while ( myEnum13->MoveNext() )
{
NetworkInterface ^ adapter = safe_cast<NetworkInterface ^>(myEnum13->Current);
IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties();
IPAddressInformationCollection ^ anyCast = adapterProperties->AnycastAddresses;
if ( anyCast->Count > 0 )
{
Console::WriteLine( adapter->Description );
System::Collections::IEnumerator^ myEnum14 = anyCast->GetEnumerator();
while ( myEnum14->MoveNext() )
{
IPAddressInformation ^ any = safe_cast<IPAddressInformation ^>(myEnum14->Current);
Console::WriteLine( " Anycast Address .......................... : {0} {1} {2}",
any->Address, any->IsTransient ? "Transient" : "",
any->IsDnsEligible ? "DNS Eligible" : "" );
count++;
}
Console::WriteLine();
}
}
if (count == 0)
{
Console::WriteLine(" No anycast addresses were found.");
Console::WriteLine();
}
}
public static void DisplayAnycastAddresses()
{
int count = 0;
Console.WriteLine("Anycast Addresses");
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in adapters)
{
IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
IPAddressInformationCollection anyCast = adapterProperties.AnycastAddresses;
if (anyCast.Count >0)
{
Console.WriteLine(adapter.Description);
foreach (IPAddressInformation any in anyCast)
{
Console.WriteLine(" Anycast Address .......................... : {0} {1} {2}",
any.Address,
any.IsTransient ? "Transient" : "",
any.IsDnsEligible ? "DNS Eligible" : ""
);
count++;
}
Console.WriteLine();
}
}
if (count == 0)
{
Console.WriteLine(" No anycast addressses were found.");
Console.WriteLine();
}
}
Public Shared Sub DisplayAnycastAddresses()
Dim count as Integer = 0
Console.WriteLine("Anycast Addresses")
Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
Dim adapter As NetworkInterface
For Each adapter In adapters
Dim adapterProperties As IPInterfaceProperties = adapter.GetIPProperties()
Dim anyCast As IPAddressInformationCollection = adapterProperties.AnycastAddresses
If anyCast.Count > 0 Then
Console.WriteLine(adapter.Description)
Dim any As IPAddressInformation
For Each any In anyCast
Console.WriteLine(" Anycast Address .......................... : {0} {1} {2}", any.Address, IIf(any.IsTransient, "Transient", ""), IIf(any.IsDnsEligible, "DNS Eligible", ""))
'TODO: For performance reasons this should be changed to nested IF statements
'TODO: For performance reasons this should be changed to nested IF statements
count += 1
Next any
Console.WriteLine()
End If
Next adapter
if count = 0 then
Console.WriteLine(" No anycast addresses were found.")
Console.WriteLine()
End if
End Sub
Poznámky
Adresa anycast identifikuje více počítačů. Pakety odesílané na adresu libovolného vysílání se odesílají do jednoho z počítačů identifikovaných adresou. Adresování Anycast je funkce IPv6, která slouží k aktualizaci tabulek směrovačů pro skupinu hostitelů.