# SelectorProvider

public abstract class **SelectorProvider** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
Service-provider class for selectors and selectable channels.

A selector provider is a concrete subclass of this class that has a
zero-argument constructor and implements the abstract methods specified
below. A given invocation of the Java virtual machine maintains a single
system-wide default provider instance, which is returned by the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectorProvider.html#provider()` method. The first invocation of that method will locate
the default provider as specified below.

The system-wide default provider is used by the static open
methods of the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/DatagramChannel.html#open()`, `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Pipe.html#open()`, `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Selector.html#open()`, `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html#open()`, and `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SocketChannel.html#open()` classes. It is also
used by the `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/System.html#inheritedChannel()`
method. A program may make use of a provider other than the default provider
by instantiating that provider and then directly invoking the open
methods defined in this class.

All of the methods in this class are safe for use by multiple concurrent
threads.

<br />

### Protected Constructor Summary

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

### Public Method Summary

|---|---|
| [Channel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Channel.html) | [inheritedChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectorProvider.html#inheritedChannel())() Returns the channel inherited from the entity that created this Java virtual machine. |
| abstract [DatagramChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/DatagramChannel.html) | [openDatagramChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectorProvider.html#openDatagramChannel(java.net.ProtocolFamily))([ProtocolFamily](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ProtocolFamily.html) family) Opens a datagram channel. |
| abstract [DatagramChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/DatagramChannel.html) | [openDatagramChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectorProvider.html#openDatagramChannel())() Opens a datagram channel. |
| abstract [Pipe](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Pipe.html) | [openPipe](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectorProvider.html#openPipe())() Opens a pipe. |
| abstract [AbstractSelector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelector.html) | [openSelector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectorProvider.html#openSelector())() Opens a selector. |
| abstract [ServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html) | [openServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectorProvider.html#openServerSocketChannel())() Opens a server-socket channel. |
| abstract [SocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SocketChannel.html) | [openSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/SelectorProvider.html#openSocketChannel())() Opens a socket channel. |
| static [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/SelectorProvider.html#provider())() Returns the system-wide default selector provider for this invocation of the Java virtual machine. |

### Inherited Method Summary

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. |

## Protected Constructors

#### protected
**SelectorProvider**
()

Initializes a new instance of this class.

##### Throws

| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | If a security manager has been installed and it denies `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/RuntimePermission.html`("selectorProvider") |
|---|---|

## Public Methods

#### public [Channel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Channel.html)
**inheritedChannel**
()

Returns the channel inherited from the entity that created this
Java virtual machine.

On many operating systems a process, such as a Java virtual
machine, can be started in a manner that allows the process to
inherit a channel from the entity that created the process. The
manner in which this is done is system dependent, as are the
possible entities to which the channel may be connected. For example,
on UNIX systems, the Internet services daemon (*inetd*) is used to
start programs to service requests when a request arrives on an
associated network port. In this example, the process that is started,
inherits a channel representing a network socket.

In cases where the inherited channel represents a network socket
then the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Channel.html` type returned
by this method is determined as follows:

- If the inherited channel represents a stream-oriented connected
  socket then a `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SocketChannel.html` is
  returned. The socket channel is, at least initially, in blocking
  mode, bound to a socket address, and connected to a peer.

- If the inherited channel represents a stream-oriented listening
  socket then a `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html` is returned. The server-socket channel is, at
  least initially, in blocking mode, and bound to a socket address.

- If the inherited channel is a datagram-oriented socket
  then a `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/DatagramChannel.html` is
  returned. The datagram channel is, at least initially, in blocking
  mode, and bound to a socket address.

In addition to the network-oriented channels described, this method
may return other kinds of channels in the future.

The first invocation of this method creates the channel that is
returned. Subsequent invocations of this method return the same
channel.

<br />

##### Returns

- The inherited channel, if any, otherwise null.

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | If an I/O error occurs |
| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | If a security manager has been installed and it denies `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/RuntimePermission.html`("inheritedChannel") |
|---|---|

#### public abstract [DatagramChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/DatagramChannel.html)
**openDatagramChannel**
([ProtocolFamily](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ProtocolFamily.html) family)

Opens a datagram channel.

##### Parameters

| family | The protocol family |
|---|---|

##### Returns

- A new datagram channel

##### Throws

| [UnsupportedOperationException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/UnsupportedOperationException.html) | If the specified protocol family is not supported |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | If an I/O error occurs |
|---|---|

#### public abstract [DatagramChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/DatagramChannel.html)
**openDatagramChannel**
()

Opens a datagram channel.

##### Returns

- The new channel

##### Throws

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

#### public abstract [Pipe](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Pipe.html)
**openPipe**
()

Opens a pipe.

##### Returns

- The new pipe

##### Throws

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

#### public abstract [AbstractSelector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelector.html)
**openSelector**
()

Opens a selector.

##### Returns

- The new selector

##### Throws

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

#### public abstract [ServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html)
**openServerSocketChannel**
()

Opens a server-socket channel.

##### Returns

- The new channel

##### Throws

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

#### public abstract [SocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SocketChannel.html)
**openSocketChannel**
()

Opens a socket channel.

##### Returns

- The new channel

##### Throws

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

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

Returns the system-wide default selector provider for this invocation of
the Java virtual machine.

The first invocation of this method locates the default provider
object as follows:

1. If the system property
   java.nio.channels.spi.SelectorProvider is defined then it is
   taken to be the fully-qualified name of a concrete provider class.
   The class is loaded and instantiated; if this process fails then an
   unspecified error is thrown.

2. If a provider class has been installed in a jar file that is
   visible to the system class loader, and that jar file contains a
   provider-configuration file named
   java.nio.channels.spi.SelectorProvider in the resource
   directory META-INF/services, then the first class name
   specified in that file is taken. The class is loaded and
   instantiated; if this process fails then an unspecified error is
   thrown.

3. Finally, if no provider has been specified by any of the above
   means then the system-default provider class is instantiated and the
   result is returned.

Subsequent invocations of this method return the provider that was
returned by the first invocation.

<br />

##### Returns

- The system-wide default selector provider