Package java.nio.channels.spi
Class SelectorProvider
java.lang.Object
java.nio.channels.spi.SelectorProvider
- Direct Known Subclasses:
SelectorProviderImpl
public abstract class SelectorProvider extends Object
SelectorProvider is an abstract base class that declares methods for
providing instances of DatagramChannel, Pipe,
Selector , ServerSocketChannel, and
SocketChannel. All the methods of this class are thread-safe.
A provider instance can be retrieved through a system property or the configuration file in a jar file; if no provider is available that way then the system default provider is returned.
-
Constructor Summary
Constructors Modifier Constructor Description protectedSelectorProvider()Constructs a newSelectorProvider. -
Method Summary
Modifier and Type Method Description ChannelinheritedChannel()Returns the channel inherited from the process that created this VM.abstract DatagramChannelopenDatagramChannel()Creates a new openDatagramChannel.abstract PipeopenPipe()Creates a newPipe.abstract AbstractSelectoropenSelector()Creates a new selector.abstract ServerSocketChannelopenServerSocketChannel()Creates a new openServerSocketChannel.abstract SocketChannelopenSocketChannel()Create a new openSocketChannel.static SelectorProviderprovider()Gets a provider instance by executing the following steps when called for the first time: if the system property "java.nio.channels.spi.SelectorProvider" is set, the value of this property is the class name of the provider returned; if there is a provider-configuration file named "java.nio.channels.spi.SelectorProvider" in META-INF/services of a jar file valid in the system class loader, the first class name is the provider's class name; otherwise, a system default provider will be returned.
-
Constructor Details
-
SelectorProvider
protected SelectorProvider()Constructs a newSelectorProvider.
-
-
Method Details
-
provider
Gets a provider instance by executing the following steps when called for the first time:- if the system property "java.nio.channels.spi.SelectorProvider" is set, the value of this property is the class name of the provider returned;
- if there is a provider-configuration file named "java.nio.channels.spi.SelectorProvider" in META-INF/services of a jar file valid in the system class loader, the first class name is the provider's class name;
- otherwise, a system default provider will be returned.
- Returns:
- the provider.
-
openDatagramChannel
Creates a new openDatagramChannel.- Returns:
- the new channel.
- Throws:
IOException- if an I/O error occurs.
-
openPipe
Creates a newPipe.- Returns:
- the new pipe.
- Throws:
IOException- if an I/O error occurs.
-
openSelector
Creates a new selector.- Returns:
- the new selector.
- Throws:
IOException- if an I/O error occurs.
-
openServerSocketChannel
Creates a new openServerSocketChannel.- Returns:
- the new channel.
- Throws:
IOException- if an I/O error occurs.
-
openSocketChannel
Create a new openSocketChannel.- Returns:
- the new channel.
- Throws:
IOException- if an I/O error occurs.
-
inheritedChannel
Returns the channel inherited from the process that created this VM. On Android, this method always returns null because stdin and stdout are never connected to a socket.- Returns:
- the channel.
- Throws:
IOException- if an I/O error occurs.
-