MulticastOption Constructors

Definition

Initializes a new instance of the MulticastOption class.

Overloads

MulticastOption(IPAddress)

Initializes a new version of the MulticastOption class for the specified IP multicast group.

MulticastOption(IPAddress, Int32)

Initializes a new instance of the MulticastOption class with the specified IP multicast group address and interface index.

MulticastOption(IPAddress, IPAddress)

Initializes a new instance of the MulticastOption class with the specified IP multicast group address and local IP address associated with a network interface.

MulticastOption(IPAddress)

Source:
MulticastOption.cs
Source:
MulticastOption.cs
Source:
MulticastOption.cs

Initializes a new version of the MulticastOption class for the specified IP multicast group.

C#
public MulticastOption(System.Net.IPAddress group);

Parameters

group
IPAddress

The IP address of the multicast group.

Exceptions

group is null.

Remarks

For machines with multiple network cards, do not use this constructor. Use the constructor that takes a group and a local IP address.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1

MulticastOption(IPAddress, Int32)

Source:
MulticastOption.cs
Source:
MulticastOption.cs
Source:
MulticastOption.cs

Initializes a new instance of the MulticastOption class with the specified IP multicast group address and interface index.

C#
public MulticastOption(System.Net.IPAddress group, int interfaceIndex);

Parameters

group
IPAddress

The IP address of the multicast group.

interfaceIndex
Int32

The index of the interface that's used to send and receive multicast packets.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1

MulticastOption(IPAddress, IPAddress)

Source:
MulticastOption.cs
Source:
MulticastOption.cs
Source:
MulticastOption.cs

Initializes a new instance of the MulticastOption class with the specified IP multicast group address and local IP address associated with a network interface.

C#
public MulticastOption(System.Net.IPAddress group, System.Net.IPAddress mcint);

Parameters

group
IPAddress

The group IP address.

mcint
IPAddress

The local IP address.

Exceptions

group is null.

-or-

mcint is null.

Examples

The following example creates a MulticastOption object.

C#

// Define a MulticastOption object specifying the multicast group
// address and the local IPAddress.
// The multicast group address is the same as the address used by the server.
s_mcastOption = new MulticastOption(s_mcastAddress, localIPAddr);

s_mcastSocket.SetSocketOption(SocketOptionLevel.IP,
                            SocketOptionName.AddMembership,
                            s_mcastOption);

Remarks

For machines with multiple network cards, you must use this constructor to create MulticastOption instances.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1