# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Protected Ctors | Methods | Inherited Methods

# MembershipKey

`public abstract class MembershipKey`
`extends Object` ``

java.lang.Object
↳ | java.nio.channels.MembershipKey

A token representing the membership of an Internet Protocol (IP) multicast group.

A membership key may represent a membership to receive all datagrams sent to the group, or it may be source-specific, meaning that it represents a membership that receives only datagrams from a specific source address. Whether or not a membership key is source-specific may be determined by invoking its `sourceAddress` method.

A membership key is valid upon creation and remains valid until the membership is dropped by invoking the `drop` method, or the channel is closed. The validity of the membership key may be tested by invoking its `isValid` method.

Where a membership key is not source-specific and the underlying operation system supports source filtering, then the `block` and `unblock` methods can be used to block or unblock multicast datagrams from particular source addresses.

See also:

- `MulticastChannel`

## Summary

### Protected constructors
`MembershipKey()` Initializes a new instance of this class.

### Public methods
`abstract MembershipKey` | `block(InetAddress source)` Block multicast datagrams from the given source address.
`abstract MulticastChannel` | `channel()` Returns the channel for which this membership key was created.
`abstract void` | `drop()` Drop membership.
`abstract InetAddress` | `group()` Returns the multicast group for which this membership key was created.
`abstract boolean` | `isValid()` Tells whether or not this membership is valid.
`abstract NetworkInterface` | `networkInterface()` Returns the network interface for which this membership key was created.
`abstract InetAddress` | `sourceAddress()` Returns the source address if this membership key is source-specific, or `null` if this membership is not source-specific.
`abstract MembershipKey` | `unblock(InetAddress source)` Unblock multicast datagrams from the given source address that was previously blocked using the `block` method.

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.

## Protected constructors

### MembershipKey

    protected MembershipKey ()

Initializes a new instance of this class.

## Public methods

### block

    public abstract MembershipKey block (InetAddress source)

Block multicast datagrams from the given source address.

If this membership key is not source-specific, and the underlying operating system supports source filtering, then this method blocks multicast datagrams from the given source address. If the given source address is already blocked then this method has no effect. After a source address is blocked it may still be possible to receive datagrams from that source. This can arise when datagrams are waiting to be received in the socket's receive buffer.

Parameters
`source` | `InetAddress`: The source address to block

Returns
`MembershipKey` | This membership key

Throws
`IllegalArgumentException` | If the `source` parameter is not a unicast address or is not the same address type as the multicast group
`IllegalStateException` | If this membership key is source-specific or is no longer valid
`UnsupportedOperationException` | If the underlying operating system does not support source filtering
`IOException` | If an I/O error occurs

### channel

    public abstract MulticastChannel channel ()

Returns the channel for which this membership key was created. This method will continue to return the channel even after the membership becomes `invalid`.

Returns
`MulticastChannel` | the channel

### drop

    public abstract void drop ()

Drop membership.

If the membership key represents a membership to receive all datagrams then the membership is dropped and the channel will no longer receive any datagrams sent to the group. If the membership key is source-specific then the channel will no longer receive datagrams sent to the group from that source address.

After membership is dropped it may still be possible to receive datagrams sent to the group. This can arise when datagrams are waiting to be received in the socket's receive buffer. After membership is dropped then the channel may `join` the group again in which case a new membership key is returned.

Upon return, this membership object will be `invalid`. If the multicast group membership is already invalid then invoking this method has no effect. Once a multicast group membership is invalid, it remains invalid forever.

### group

    public abstract InetAddress group ()

Returns the multicast group for which this membership key was created. This method will continue to return the group even after the membership becomes `invalid`.

Returns
`InetAddress` | the multicast group

### isValid

    public abstract boolean isValid ()

Tells whether or not this membership is valid.

A multicast group membership is valid upon creation and remains valid until the membership is dropped by invoking the `drop` method, or the channel is closed.

Returns
`boolean` | `true` if this membership key is valid, `false` otherwise

### networkInterface

    public abstract NetworkInterface networkInterface ()

Returns the network interface for which this membership key was created. This method will continue to return the network interface even after the membership becomes `invalid`.

Returns
`NetworkInterface` | the network interface

### sourceAddress

    public abstract InetAddress sourceAddress ()

Returns the source address if this membership key is source-specific, or `null` if this membership is not source-specific.

Returns
`InetAddress` | The source address if this membership key is source-specific, otherwise `null`

### unblock

    public abstract MembershipKey unblock (InetAddress source)

Unblock multicast datagrams from the given source address that was previously blocked using the `block` method.

Parameters
`source` | `InetAddress`: The source address to unblock

Returns
`MembershipKey` | This membership key

Throws
`IllegalStateException` | If the given source address is not currently blocked or the membership key is no longer valid

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*