System.Net.Sockets.MulticastOption Class

Assembly: System.dll
Namespace: System.Net.Sockets
Summary
Contains IP address values for IP multicast packets.
C# Syntax:
public class MulticastOption
Remarks
The MulticastOption class sets IP address values when joining or leaving an IP multicast group. It is used with the Socket.SetSocketOption and Socket.GetSocketOption methods when the optionName parameter is set to SocketOptionName.AddMembership or SocketOptionName.DropMembership.
Example
The following examples joins the default IP interface to an IP multicast group. It assumes that groupIP is an IPAddress instance that has been set to the IP multicast group address in the range 224.0.0.0 to 239.255.255.255.
 Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp ); 
 sock.SetSocketOption(SocketOptionLevel.IP, 
    SocketOptionName.AddMembership, 
    new MulticastOption( groupIP ));


    
See also:
System.Net.Sockets Namespace

System.Net.Sockets.MulticastOption Member List:

Public Constructors
ctor #1 Overloaded:
.ctor(IPAddress group)

Initializes a new version of the MulticastOption class for the specified IP multicast group.
ctor #2 Overloaded:
.ctor(IPAddress group, IPAddress mcint)

Initializes a new instance of the MulticastOption class with the specified IP multicast group address and local interface address.
Public Properties
Group Read-write

Gets or sets the IP address of a multicast group.
LocalAddress Read-write

Gets or sets the local address associated with a multicast group.
Public Methods
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Net.Sockets.MulticastOption Member Details

Overloaded ctor #1
Summary
Initializes a new version of the MulticastOption class for the specified IP multicast group.
C# Syntax:
public MulticastOption(
   IPAddress group
);
Parameters:

group

The IP address of the multicast group.

Exceptions
Exception Type Condition
ArgumentNullException group is null.

Return to top


Overloaded ctor #2
Summary
Initializes a new instance of the MulticastOption class with the specified IP multicast group address and local interface address.
C# Syntax:
public MulticastOption(
   IPAddress group,
   IPAddress mcint
);
Parameters:

group

The group IP address.

mcint

The local IP address.

Exceptions
Exception Type Condition
ArgumentNullException group is null

-or-

mcint is null.

Return to top


Property: Group (read-write)
Summary
Gets or sets the IP address of a multicast group.
C# Syntax:
public IPAddress Group {get; set;}
Remarks
Valid IP addresses for multicast packets are in the range 224.0.0.0 to 239.255.255.255.

Return to top


Property: LocalAddress (read-write)
Summary
Gets or sets the local address associated with a multicast group.
C# Syntax:
public IPAddress LocalAddress {get; set;}
Remarks
The MulticastOption.LocalAddress property contains the IP address of the interface associated with the multicast group membership. If MulticastOption.LocalAddress is set to IPAddress.Any, the default interface is used.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~MulticastOption();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.