Module org.newsclub.net.unix
Package org.newsclub.net.unix
Class AFSelectorProvider<A extends AFSocketAddress>
java.lang.Object
java.nio.channels.spi.SelectorProvider
org.newsclub.net.unix.AFSelectorProvider<A>
- Type Parameters:
A
- The concreteAFSocketAddress
that is supported by this type.
- Direct Known Subclasses:
AFSYSTEMSelectorProvider
,AFTIPCSelectorProvider
,AFUNIXSelectorProvider
,AFVSOCKSelectorProvider
Service-provider class for junixsocket selectors and selectable channels.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract AFAddressFamily
<@NonNull A> Returns the address family supported by this implementation.protected final int
domainId()
Returns the domain ID for the supported protocol, as specified byNativeUnixSocket
.Constructs a new socket.protected abstract <Y extends AFSomeSocket>
AFSocketPair<Y> newSocketPair
(Y s1, Y s2) Constructs a new socket pair from two sockets.abstract AFDatagramChannel
<A> openDatagramChannel
(ProtocolFamily family) abstract AFDatagramChannel
<A> Opens aDatagramChannel
using the given socket type.AFSocketPair
<? extends AFDatagramChannel<A>> Opens a socket pair of interconnected datagram channels.AFSocketPair
<? extends AFDatagramChannel<A>> Opens a socket pair of interconnectedDatagramChannel
s, using the givenAFSocketType
.final AFPipe
openPipe()
final AbstractSelector
abstract AFServerSocketChannel
<A> abstract AFServerSocketChannel
<A> Opens a server-socket channel bound on the givenSocketAddress
.openSocketChannel
(ProtocolFamily family) abstract AFSocketChannel
<A> Opens a socket channel connected to the givenSocketAddress
.AFSocketPair
<? extends AFSocketChannel<A>> Opens a socket pair of interconnected channels.protected abstract ProtocolFamily
Returns the protocol family supported by this implementation.static SelectorProvider
provider()
Returns the singleton instance for an "fallback" provider that supports the methods takingProtocolFamily
, as long as a junixsocket-specificAFProtocolFamily
is used.Methods inherited from class java.nio.channels.spi.SelectorProvider
inheritedChannel
-
Constructor Details
-
AFSelectorProvider
protected AFSelectorProvider()Constructs a newAFSelectorProvider
.
-
-
Method Details
-
newSocketPair
Constructs a new socket pair from two sockets.- Type Parameters:
Y
- The type of the pair.- Parameters:
s1
- Some socket, the first one.s2
- Some socket, the second one.- Returns:
- The pair.
-
newSocket
Constructs a new socket.- Returns:
- The socket instance.
- Throws:
IOException
- on error.
-
protocolFamily
Returns the protocol family supported by this implementation.- Returns:
- The protocol family.
-
addressFamily
Returns the address family supported by this implementation.- Returns:
- The address family.
-
domainId
protected final int domainId()Returns the domain ID for the supported protocol, as specified byNativeUnixSocket
.- Returns:
- The domain ID.
-
openSocketChannelPair
Opens a socket pair of interconnected channels.- Returns:
- The new channel pair.
- Throws:
IOException
- on error.
-
openDatagramChannelPair
Opens a socket pair of interconnected datagram channels.- Returns:
- The new channel pair.
- Throws:
IOException
- on error.
-
openDatagramChannelPair
public AFSocketPair<? extends AFDatagramChannel<A>> openDatagramChannelPair(AFSocketType type) throws IOException Opens a socket pair of interconnectedDatagramChannel
s, using the givenAFSocketType
.- Parameters:
type
- The socket type.- Returns:
- The new channel pair.
- Throws:
IOException
- on error.
-
openDatagramChannel
- Specified by:
openDatagramChannel
in classSelectorProvider
- Throws:
IOException
-
openDatagramChannel
Opens aDatagramChannel
using the given socket type.- Parameters:
type
- The socket type.- Returns:
- the new channel
- Throws:
IOException
- on error.
-
openPipe
- Specified by:
openPipe
in classSelectorProvider
- Throws:
IOException
-
openSelector
- Specified by:
openSelector
in classSelectorProvider
- Throws:
IOException
-
openServerSocketChannel
- Specified by:
openServerSocketChannel
in classSelectorProvider
- Throws:
IOException
-
openServerSocketChannel
public abstract AFServerSocketChannel<A> openServerSocketChannel(SocketAddress sa) throws IOException Opens a server-socket channel bound on the givenSocketAddress
.- Parameters:
sa
- The socket address to bind on.- Returns:
- The new channel
- Throws:
IOException
- on error.
-
openSocketChannel
- Specified by:
openSocketChannel
in classSelectorProvider
- Throws:
IOException
-
openSocketChannel
Opens a socket channel connected to the givenSocketAddress
.- Parameters:
sa
- The socket address to connect to.- Returns:
- The new channel
- Throws:
IOException
- on error.
-
openSocketChannel
- Overrides:
openSocketChannel
in classSelectorProvider
- Throws:
IOException
-
openServerSocketChannel
- Overrides:
openServerSocketChannel
in classSelectorProvider
- Throws:
IOException
-
openDatagramChannel
- Specified by:
openDatagramChannel
in classSelectorProvider
- Throws:
IOException
-
provider
Returns the singleton instance for an "fallback" provider that supports the methods takingProtocolFamily
, as long as a junixsocket-specificAFProtocolFamily
is used.- Returns:
- The instance.
-