IPInterfaceProperties.MulticastAddresses Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient les adresses multicast assignées à cette interface.
public:
abstract property System::Net::NetworkInformation::MulticastIPAddressInformationCollection ^ MulticastAddresses { System::Net::NetworkInformation::MulticastIPAddressInformationCollection ^ get(); };
public abstract System.Net.NetworkInformation.MulticastIPAddressInformationCollection MulticastAddresses { get; }
member this.MulticastAddresses : System.Net.NetworkInformation.MulticastIPAddressInformationCollection
Public MustOverride ReadOnly Property MulticastAddresses As MulticastIPAddressInformationCollection
Valeur de propriété
MulticastIPAddressInformationCollection qui contient les adresses multicast de cette interface.
Exemples
L’exemple de code suivant affiche les adresses de multidiffusion pour les interfaces réseau sur l’ordinateur local.
void DisplayMulticastAddresses()
{
int count = 0;
Console::WriteLine( "Multicast Addresses" );
array<NetworkInterface^>^adapters = NetworkInterface::GetAllNetworkInterfaces();
System::Collections::IEnumerator^ myEnum15 = adapters->GetEnumerator();
while ( myEnum15->MoveNext() )
{
NetworkInterface ^ adapter = safe_cast<NetworkInterface ^>(myEnum15->Current);
IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties();
MulticastIPAddressInformationCollection ^ multiCast = adapterProperties->MulticastAddresses;
if ( multiCast->Count > 0 )
{
Console::WriteLine( adapter->Description );
System::Collections::IEnumerator^ myEnum16 = multiCast->GetEnumerator();
while ( myEnum16->MoveNext() )
{
MulticastIPAddressInformation ^ multi = safe_cast<MulticastIPAddressInformation ^>(myEnum16->Current);
Console::WriteLine( " Multicast Address ....................... : {0} {1} {2}",
multi->Address, multi->IsTransient ? "Transient" : "",
multi->IsDnsEligible ? "DNS Eligible" : "" );
count++;
}
Console::WriteLine();
}
}
if (count == 0)
{
Console::WriteLine(" No multicast addresses were found.");
Console::WriteLine();
}
}
public static void DisplayMulticastAddresses()
{
int count = 0;
Console.WriteLine("Multicast Addresses");
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in adapters)
{
IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
MulticastIPAddressInformationCollection multiCast = adapterProperties.MulticastAddresses;
if (multiCast.Count > 0)
{
Console.WriteLine(adapter.Description);
foreach (IPAddressInformation multi in multiCast)
{
Console.WriteLine(" Multicast Address ....................... : {0} {1} {2}",
multi.Address,
multi.IsTransient ? "Transient" : "",
multi.IsDnsEligible ? "DNS Eligible" : ""
);
count++;
}
Console.WriteLine();
}
}
if (count == 0)
{
Console.WriteLine(" No multicast addressses were found.");
Console.WriteLine();
}
}
Public Shared Sub DisplayMulticastAddresses()
Dim count as Integer = 0
Console.WriteLine("Multicast Addresses")
Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
Dim adapter As NetworkInterface
For Each adapter In adapters
Dim adapterProperties As IPInterfaceProperties = adapter.GetIPProperties()
Dim multiCast As MulticastIPAddressInformationCollection = adapterProperties.MulticastAddresses
If multiCast.Count > 0 Then
Console.WriteLine(adapter.Description)
Dim multi As IPAddressInformation
For Each multi In multiCast
Console.WriteLine(" Multicast Address ....................... : {0} {1} {2}", multi.Address, IIf(multi.IsTransient, "Transient", ""), IIf(multi.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 multi
Console.WriteLine()
End If
Next adapter
if count = 0 then
Console.WriteLine(" No multicast addresses were found.")
Console.WriteLine()
End if
End Sub
Remarques
Une adresse de multidiffusion identifie plusieurs ordinateurs. Les paquets envoyés à une adresse de multidiffusion sont envoyés à tous les ordinateurs identifiés par l’adresse.