Export (0) Print
Expand All

UdpClient.JoinMulticastGroup Method

Adds a UdpClient to a multicast group.

Overload List

Adds a UdpClient to a multicast group.

[Visual Basic] Overloads Public Sub JoinMulticastGroup(IPAddress)
[C#] public void JoinMulticastGroup(IPAddress);
[C++] public: void JoinMulticastGroup(IPAddress*);
[JScript] public function JoinMulticastGroup(IPAddress);

[Visual Basic] Overloads Public Sub JoinMulticastGroup(Integer, IPAddress)
[C#] public void JoinMulticastGroup(int, IPAddress);
[C++] public: void JoinMulticastGroup(int, IPAddress*);
[JScript] public function JoinMulticastGroup(int, IPAddress);

Adds a UdpClient to a multicast group with the specified Time to Live (TTL).

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Sub JoinMulticastGroup(IPAddress, Integer)
[C#] public void JoinMulticastGroup(IPAddress, int);
[C++] public: void JoinMulticastGroup(IPAddress*, int);
[JScript] public function JoinMulticastGroup(IPAddress, int);

Example

[Visual Basic, C#, C++] The following example demonstrates how to join a multicast group by providing two parameters, a multicast address, and a number representing the TTL.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of JoinMulticastGroup. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Dim udpClient As New UdpClient()
' Creates an IP address to use to join and drop the multicast group.
Dim multicastIpAddress As IPAddress = IPAddress.Parse("239.255.255.255")

Try
   ' The packet dies after 50 router hops.
   udpClient.JoinMulticastGroup(multicastIpAddress, 50)
Catch e As Exception
   Console.WriteLine(e.ToString())
End Try

[C#] 
UdpClient udpClient = new UdpClient();
// Creates an IPAddress to use to join and drop the multicast group.
IPAddress multicastIpAddress = IPAddress.Parse("239.255.255.255");

try{
     // The packet dies after 50 router hops.
     udpClient.JoinMulticastGroup(multicastIpAddress, 50);
}
catch ( Exception e ){
    Console.WriteLine( e.ToString());
}

[C++] 
UdpClient* udpClient = new UdpClient();
// Creates an IPAddress to use to join and drop the multicast group.
IPAddress* multicastIpAddress = IPAddress::Parse(S"239.255.255.255");

try{
     // The packet dies after 50 router hops.
     udpClient->JoinMulticastGroup(multicastIpAddress, 50);
}
catch ( Exception* e ){
    Console::WriteLine( e->ToString());
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

UdpClient Class | UdpClient Members | System.Net.Sockets Namespace

Show:
© 2014 Microsoft