public void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf)
        throws IOException {
        if (isClosed())
            throw new SocketException("Socket is closed");

        if (mcastaddr == null || !(mcastaddr instanceof InetSocketAddress))
            throw new IllegalArgumentException("Unsupported address type");

        if (oldImpl)
            throw new UnsupportedOperationException();

        checkAddress(((InetSocketAddress)mcastaddr).getAddress(), "joinGroup");
        SecurityManager security = System.getSecurityManager();
        if (security != null) {
            security.checkMulticast(((InetSocketAddress)mcastaddr).getAddress());
        }

        if (!((InetSocketAddress)mcastaddr).getAddress().isMulticastAddress()) {
            throw new SocketException("Not a multicast address");
        }

        getImpl().joinGroup(mcastaddr, netIf);
    }
public void joinGroup ( SocketAddress mcastaddr , NetworkInterface netIf ) throws IOException { if ( isClosed ( ) ) throw new SocketException ( "Socket is closed" ) ; if ( mcastaddr == null || ! ( mcastaddr instanceof InetSocketAddress ) ) throw new IllegalArgumentException ( "Unsupported address type" ) ; if ( oldImpl ) throw new UnsupportedOperationException ( ) ; checkAddress ( ( ( InetSocketAddress ) mcastaddr ) . getAddress ( ) , "joinGroup" ) ; SecurityManager security = System . getSecurityManager ( ) ; if ( security != null ) { security . checkMulticast ( ( ( InetSocketAddress ) mcastaddr ) . getAddress ( ) ) ; } if ( ! ( ( InetSocketAddress ) mcastaddr ) . getAddress ( ) . isMulticastAddress ( ) ) { throw new SocketException ( "Not a multicast address" ) ; } getImpl ( ) . joinGroup ( mcastaddr , netIf ) ; }
Joins the specified multicast group at the specified interface.

<p>If there is a security manager, this method first
calls its {@code checkMulticast} method
with the {@code mcastaddr} argument
as its argument.

@param mcastaddr is the multicast address to join
@param netIf specifies the local interface to receive multicast
datagram packets, or <i>null</i> to defer to the interface set by
{@link MulticastSocket#setInterface(InetAddress)} or
{@link MulticastSocket#setNetworkInterface(NetworkInterface)}

@exception IOException if there is an error joining
or when the address is not a multicast address.
@exception  SecurityException  if a security manager exists and its
{@code checkMulticast} method doesn't allow the join.
@throws  IllegalArgumentException if mcastaddr is null or is a
SocketAddress subclass not supported by this socket

@see SecurityManager#checkMulticast(InetAddress)
@since 1.4