# AbstractSelectableChannel

public abstract class **AbstractSelectableChannel** extends [SelectableChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html)  

|---|---|---|
| Known Direct Subclasses [DatagramChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/DatagramChannel.html), [Pipe.SinkChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Pipe.SinkChannel.html), [Pipe.SourceChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Pipe.SourceChannel.html), [ServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html), [SocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SocketChannel.html) |---|---| | [DatagramChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/DatagramChannel.html) | A selectable channel for datagram-oriented sockets. | | [Pipe.SinkChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Pipe.SinkChannel.html) | A channel representing the writable end of a `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Pipe.html`. | | [Pipe.SourceChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Pipe.SourceChannel.html) | A channel representing the readable end of a `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Pipe.html`. | | [ServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html) | A selectable channel for stream-oriented listening sockets. | | [SocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SocketChannel.html) | A selectable channel for stream-oriented connecting sockets. | |||

Base implementation class for selectable channels.

This class defines methods that handle the mechanics of channel
registration, deregistration, and closing. It maintains the current
blocking mode of this channel as well as its current set of selection keys.
It performs all of the synchronization required to implement the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html` specification. Implementations of the
abstract protected methods defined in this class need not synchronize
against other threads that might be engaged in the same operations.

<br />

### Protected Constructor Summary

|---|---|
|   | [AbstractSelectableChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#AbstractSelectableChannel(java.nio.channels.spi.SelectorProvider))([SelectorProvider](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectorProvider.html) provider) Initializes a new instance of this class. |

### Public Method Summary

|---|---|
| final [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [blockingLock](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#blockingLock())() Retrieves the object upon which the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#configureBlocking(boolean)` and `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#register(java.nio.channels.Selector,%20int)` methods synchronize. |
| final [SelectableChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html) | [configureBlocking](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#configureBlocking(boolean))(boolean block) Adjusts this channel's blocking mode. |
| final boolean | [isBlocking](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#isBlocking())() Tells whether or not every I/O operation on this channel will block until it completes. |
| final boolean | [isRegistered](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#isRegistered())() Tells whether or not this channel is currently registered with any selectors. |
| final [SelectionKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html) | [keyFor](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#keyFor(java.nio.channels.Selector))([Selector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Selector.html) sel) Retrieves the key representing the channel's registration with the given selector. |
| final [SelectorProvider](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectorProvider.html) | [provider](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#provider())() Returns the provider that created this channel. |
| final [SelectionKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html) | [register](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#register(java.nio.channels.Selector,%20int,%20java.lang.Object))([Selector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Selector.html) sel, int ops, [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) att) Registers this channel with the given selector, returning a selection key. |

### Protected Method Summary

|---|---|
| final void | [implCloseChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#implCloseChannel())() Closes this channel. |
| abstract void | [implCloseSelectableChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#implCloseSelectableChannel())() Closes this selectable channel. |
| abstract void | [implConfigureBlocking](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#implConfigureBlocking(boolean))(boolean block) Adjusts this channel's blocking mode. |

### Inherited Method Summary

From class [java.nio.channels.SelectableChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html)

|---|---|
| abstract [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [blockingLock](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#blockingLock())() Retrieves the object upon which the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#configureBlocking(boolean)` and `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#register(java.nio.channels.Selector,%20int)` methods synchronize. |
| abstract [SelectableChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html) | [configureBlocking](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#configureBlocking(boolean))(boolean block) Adjusts this channel's blocking mode. |
| abstract boolean | [isBlocking](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#isBlocking())() Tells whether or not every I/O operation on this channel will block until it completes. |
| abstract boolean | [isRegistered](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#isRegistered())() Tells whether or not this channel is currently registered with any selectors. |
| abstract [SelectionKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html) | [keyFor](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#keyFor(java.nio.channels.Selector))([Selector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Selector.html) sel) Retrieves the key representing the channel's registration with the given selector. |
| abstract [SelectorProvider](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectorProvider.html) | [provider](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#provider())() Returns the provider that created this channel. |
| abstract [SelectionKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html) | [register](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#register(java.nio.channels.Selector,%20int,%20java.lang.Object))([Selector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Selector.html) sel, int ops, [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) att) Registers this channel with the given selector, returning a selection key. |
| final [SelectionKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html) | [register](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#register(java.nio.channels.Selector,%20int))([Selector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Selector.html) sel, int ops) Registers this channel with the given selector, returning a selection key. |
| abstract int | [validOps](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#validOps())() Returns an [operation set](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectionKey#opsets) identifying this channel's supported operations. |

From class [java.nio.channels.spi.AbstractInterruptibleChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractInterruptibleChannel.html)

|---|---|
| final void | [begin](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractInterruptibleChannel.html#begin())() Marks the beginning of an I/O operation that might block indefinitely. |
| final void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractInterruptibleChannel.html#close())() Closes this channel. |
| final void | [end](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractInterruptibleChannel.html#end(boolean))(boolean completed) Marks the end of an I/O operation that might block indefinitely. |
| abstract void | [implCloseChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractInterruptibleChannel.html#implCloseChannel())() Closes this channel. |
| final boolean | [isOpen](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractInterruptibleChannel.html#isOpen())() Tells whether or not this channel is open. |

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

From interface [java.nio.channels.Channel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Channel.html)

|---|---|
| abstract void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Channel.html#close())() Closes this channel. |
| abstract boolean | [isOpen](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Channel.html#isOpen())() Tells whether or not this channel is open. |

From interface [java.nio.channels.InterruptibleChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/InterruptibleChannel.html)

|---|---|
| abstract void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/InterruptibleChannel.html#close())() Closes this channel. |

From interface [java.io.Closeable](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Closeable.html)

|---|---|
| abstract void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Closeable.html#close())() Closes this stream and releases any system resources associated with it. |

From interface [java.lang.AutoCloseable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/AutoCloseable.html)

|---|---|
| abstract void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/AutoCloseable.html#close())() Closes this resource, relinquishing any underlying resources. |

## Protected Constructors

#### protected
**AbstractSelectableChannel**
([SelectorProvider](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectorProvider.html) provider)

Initializes a new instance of this class.

##### Parameters

| provider | The provider that created this channel |
|---|---|

## Public Methods

#### public final [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)
**blockingLock**
()

Retrieves the object upon which the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#configureBlocking(boolean)` and `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html#register(java.nio.channels.Selector,%20int)` methods synchronize.
This is often useful in the implementation of adaptors that require a
specific blocking mode to be maintained for a short period of time.

##### Returns

- The blocking-mode lock object

#### public final [SelectableChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html)
**configureBlocking**
(boolean block)

Adjusts this channel's blocking mode.

If the given blocking mode is different from the current blocking
mode then this method invokes the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#implConfigureBlocking(boolean)` method, while holding the appropriate locks, in
order to change the mode.

<br />

##### Parameters

| block | If true then this channel will be placed in blocking mode; if false then it will be placed non-blocking mode |
|---|---|

##### Returns

- This selectable channel

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) |   |
|---|---|

#### public final boolean
**isBlocking**
()

Tells whether or not every I/O operation on this channel will block
until it completes. A newly-created channel is always in blocking mode.

If this channel is closed then the value returned by this method is
not specified.

<br />

##### Returns

- true if, and only if, this channel is in blocking mode

#### public final boolean
**isRegistered**
()

Tells whether or not this channel is currently registered with any
selectors. A newly-created channel is not registered.

Due to the inherent delay between key cancellation and channel
deregistration, a channel may remain registered for some time after all
of its keys have been cancelled. A channel may also remain registered
for some time after it is closed.

<br />

##### Returns

- true if, and only if, this channel is registered

#### public final [SelectionKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html)
**keyFor**
([Selector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Selector.html) sel)

Retrieves the key representing the channel's registration with the given
selector.

##### Parameters

| sel | The selector |
|---|---|

##### Returns

- The key returned when this channel was last registered with the given selector, or null if this channel is not currently registered with that selector

#### public final [SelectorProvider](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectorProvider.html)
**provider**
()

Returns the provider that created this channel.

##### Returns

- The provider that created this channel

#### public final [SelectionKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html)
**register**
([Selector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Selector.html) sel, int ops, [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) att)

Registers this channel with the given selector, returning a selection key.

This method first verifies that this channel is open and that the
given initial interest set is valid.

If this channel is already registered with the given selector then
the selection key representing that registration is returned after
setting its interest set to the given value.

Otherwise this channel has not yet been registered with the given
selector, so the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelector.html#register(java.nio.channels.spi.AbstractSelectableChannel,%20int,%20java.lang.Object)` method of
the selector is invoked while holding the appropriate locks. The
resulting key is added to this channel's key set before being returned.

<br />

##### Parameters

| sel | The selector with which this channel is to be registered |
| ops | The interest set for the resulting key |
| att | The attachment for the resulting key; may be null |
|---|---|

##### Returns

- A key representing the registration of this channel with the given selector

##### Throws

| [ClosedSelectorException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ClosedSelectorException.html) |   |
| [IllegalBlockingModeException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/IllegalBlockingModeException.html) |   |
| [IllegalSelectorException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/IllegalSelectorException.html) |   |
| [CancelledKeyException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/CancelledKeyException.html) |   |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) |   |
| [ClosedChannelException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ClosedChannelException.html) |   |
|---|---|

## Protected Methods

#### protected final void
**implCloseChannel**
()

Closes this channel.

This method, which is specified in the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractInterruptibleChannel.html` class and is invoked by the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Channel.html#close()` method, in turn invokes the
`https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#implCloseSelectableChannel()` method in
order to perform the actual work of closing this channel. It then
cancels all of this channel's keys.

<br />

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) |   |
|---|---|

#### protected abstract void
**implCloseSelectableChannel**
()

Closes this selectable channel.

This method is invoked by the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Channel.html#close()` method in order to perform the actual work of closing the
channel. This method is only invoked if the channel has not yet been
closed, and it is never invoked more than once.

An implementation of this method must arrange for any other thread
that is blocked in an I/O operation upon this channel to return
immediately, either by throwing an exception or by returning normally.

<br />

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | If an I/O error occurs |
|---|---|

#### protected abstract void
**implConfigureBlocking**
(boolean block)

Adjusts this channel's blocking mode.

This method is invoked by the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html#configureBlocking(boolean)` method in order to perform the actual work of
changing the blocking mode. This method is only invoked if the new mode
is different from the current mode.

<br />

##### Parameters

| block | If true then this channel will be placed in blocking mode; if false then it will be placed non-blocking mode |
|---|---|

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | If an I/O error occurs |
|---|---|