Java MulticastSocket joinGroup() Method

joinGroup(InetAddress mcastaddr) is the method of MulticastSocket class. This method is used to join multicast group. The behavior of the group can be affected by setInterface or setNetworkInterface.

Syntax

Parameter

mcastaddr - It is the multicast address to join the group.

Throw

IOException - This exception occurs while there is error while joining or the address is not multicast address or the platform does not support multicasting.

SecurityException - This exception occurs if a security manager exists and its checkMulticast method doesn't allow the join.

Example 1

Test it Now

Output:

Group joined using joinGroup method....




Latest Courses