Adds a UdpClient to a multicast group.
Assembly: System (in System.dll)
Public Sub JoinMulticastGroup ( _ ifindex As Integer, _ multicastAddr As IPAddress _ )
public void JoinMulticastGroup( int ifindex, IPAddress multicastAddr )
public: void JoinMulticastGroup( int ifindex, IPAddress^ multicastAddr )
member JoinMulticastGroup : ifindex:int * multicastAddr:IPAddress -> unit
Parameters
- ifindex
- Type: System.Int32
The interface index associated with the local IP address on which to join the multicast group.
- multicastAddr
- Type: System.Net.IPAddress
The multicast IPAddress of the group you want to join.
| Exception | Condition |
|---|---|
| ObjectDisposedException |
The underlying Socket has been closed. |
| SocketException |
An error occurred when accessing the socket. See the Remarks section for more information. |
Before joining a multicast group, be sure the socket is bound to the port or endpoint. You can do this by calling one of the constructors that accepts a port or an endpoint as parameter.
The infindex parameter is used to identify a hardware interface on the same link.
Note
|
|---|
|
There are several multicast address ranges to choose from. Refer to the IETF RFC 2375. |
Note
|
|---|
|
You cannot call JoinMulticastGroup on a UdpClient constructed without a specific local port (that is, using the UdpClient.UdpClient() or UdpClient.UdpClient(AddressFamily) constructor). |
' Instantiate IPv6MulticastOption using another ' overloaded constructor. Dim ipv6MulticastOption2 As New IPv6MulticastOption(group, interfaceIndex) ' Store the IPAdress multicast options. group = ipv6MulticastOption2.Group interfaceIndex = ipv6MulticastOption2.InterfaceIndex ' Display the IPv6MulticastOption2 properties. Console.WriteLine(("IPv6MulticastOption.Group: [" + group.ToString() + "]")) Console.WriteLine(("IPv6MulticastOption.InterfaceIndex: [" + interfaceIndex.ToString() + "]")) ' Join the specified multicast group using one of the ' JoinMulticastGroup overloaded methods. clientOriginator.JoinMulticastGroup(Fix(interfaceIndex), group)
// Instantiate IPv6MulticastOption using another // overloaded constructor. IPv6MulticastOption ipv6MulticastOption2 = new IPv6MulticastOption(group, interfaceIndex); // Store the IPAdress multicast options. group = ipv6MulticastOption2.Group; interfaceIndex = ipv6MulticastOption2.InterfaceIndex; // Display the IPv6MulticastOption2 properties. Console.WriteLine("IPv6MulticastOption.Group: [" + group + "]"); Console.WriteLine("IPv6MulticastOption.InterfaceIndex: [" + interfaceIndex + "]"); // Join the specified multicast group using one of the // JoinMulticastGroup overloaded methods. clientOriginator.JoinMulticastGroup((int)interfaceIndex, group);
// Instantiate IPv6MulticastOption using another // overloaded constructor. IPv6MulticastOption^ ipv6MulticastOption2 = gcnew IPv6MulticastOption( group,interfaceIndex ); // Store the IPAdress multicast options. group = ipv6MulticastOption2->Group; interfaceIndex = ipv6MulticastOption2->InterfaceIndex; // Display the IPv6MulticastOption2 properties. Console::WriteLine( "IPv6MulticastOption::Group: [ {0} ]", group ); Console::WriteLine( "IPv6MulticastOption::InterfaceIndex: [ {0} ]", interfaceIndex ); // Join the specified multicast group using one of the // JoinMulticastGroup overloaded methods. clientOriginator->JoinMulticastGroup( (int)interfaceIndex, group );
.NET Framework
Supported in: 4, 3.5, 3.0, 2.0, 1.1.NET Framework Client Profile
Supported in: 4, 3.5 SP1Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note