Java MulticastSocket leaveGroup() Method

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

Syntax

Parameter

mcastaddr - it is the multicast address to leave the group.

Throw

IOException - this exception occurs whenever there is error while leaving 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:

leaving group using leaveGroup method....




Latest Courses