Redigera

Dela via


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.

public:
 MulticastOption(System::Net::IPAddress ^ group);
public MulticastOption (System.Net.IPAddress group);
new System.Net.Sockets.MulticastOption : System.Net.IPAddress -> System.Net.Sockets.MulticastOption
Public Sub New (group As IPAddress)

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

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.

public:
 MulticastOption(System::Net::IPAddress ^ group, int interfaceIndex);
public MulticastOption (System.Net.IPAddress group, int interfaceIndex);
new System.Net.Sockets.MulticastOption : System.Net.IPAddress * int -> System.Net.Sockets.MulticastOption
Public Sub New (group As IPAddress, interfaceIndex As Integer)

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

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.

public:
 MulticastOption(System::Net::IPAddress ^ group, System::Net::IPAddress ^ mcint);
public MulticastOption (System.Net.IPAddress group, System.Net.IPAddress mcint);
new System.Net.Sockets.MulticastOption : System.Net.IPAddress * System.Net.IPAddress -> System.Net.Sockets.MulticastOption
Public Sub New (group As IPAddress, mcint As IPAddress)

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.

// Define a MuticastOption object specifying the multicast group
// address and the local IPAddress.
// The multicast group address is the same one used by the server.
mcastOption = gcnew MulticastOption( mcastAddress,localIPAddr );
mcastSocket->SetSocketOption( SocketOptionLevel::IP, SocketOptionName::AddMembership, mcastOption );

// 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);
' 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.
mcastOption = New MulticastOption(mcastAddress, localIPAddr)

mcastSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, mcastOption)

Remarks

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

Applies to