Module org.newsclub.net.unix
Package org.newsclub.net.unix
Class AFServerSocketChannel<A extends AFSocketAddress>
java.lang.Object
java.nio.channels.spi.AbstractInterruptibleChannel
java.nio.channels.SelectableChannel
java.nio.channels.spi.AbstractSelectableChannel
java.nio.channels.ServerSocketChannel
org.newsclub.net.unix.AFServerSocketChannel<A>
- Type Parameters:
A- The concreteAFSocketAddressthat is supported by this type.
- All Implemented Interfaces:
Closeable,AutoCloseable,Channel,InterruptibleChannel,NetworkChannel,AFSomeSocketChannel,AFSomeSocketThing,FileDescriptorAccess
- Direct Known Subclasses:
AFSYSTEMServerSocketChannel,AFTIPCServerSocketChannel,AFUNIXServerSocketChannel,AFVSOCKServerSocketChannel
public abstract class AFServerSocketChannel<A extends AFSocketAddress>
extends ServerSocketChannel
implements FileDescriptorAccess, AFSomeSocketChannel
A selectable channel for stream-oriented listening sockets.
- Author:
- Christian Kohlschütter
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAFServerSocketChannel(AFServerSocket<A> socket, AFSelectorProvider<A> sp) Creates a newAFServerSocketChannelinstance. -
Method Summary
Modifier and TypeMethodDescriptionaccept()final AFServerSocketChannel<A> bind(SocketAddress local, int backlog) final FileDescriptorReturns the correspondingFileDescriptor.final @Nullable Afinal @Nullable AReturns the socket's local socket address, ornullif unavailable or if there was a problem retrieving it.<T> TgetOption(SocketOption<T> name) protected final voidprotected final voidimplConfigureBlocking(boolean block) final booleanChecks if thisAFServerSocketChannel's file should be removed uponAbstractInterruptibleChannel.close().final booleanChecks if the local socket address returned bygetLocalAddress()is still valid.static ServerSocketChannelopen(ProtocolFamily family) Opens a server-socket channel.final voidsetDeleteOnClose(boolean b) Enables/disables deleting thisAFServerSocketChannel's file (or other resource type) uponAbstractInterruptibleChannel.close().<T> AFServerSocketChannel<A> setOption(SocketOption<T> name, T value) voidsetShutdownOnClose(boolean enabled) Configures whether the socket should be shutdown uponCloseable.close(), which is the default.final AFServerSocket<A> socket()final Set<SocketOption<?>> Methods inherited from class java.nio.channels.ServerSocketChannel
bind, open, validOpsMethods inherited from class java.nio.channels.spi.AbstractSelectableChannel
blockingLock, configureBlocking, implCloseChannel, isBlocking, isRegistered, keyFor, provider, registerMethods inherited from class java.nio.channels.SelectableChannel
registerMethods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel
begin, close, end, isOpenMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.newsclub.net.unix.AFSomeSocketChannel
configureBlocking, isBlockingMethods inherited from interface java.nio.channels.InterruptibleChannel
close
-
Constructor Details
-
AFServerSocketChannel
Creates a newAFServerSocketChannelinstance.- Parameters:
socket- The correspondingServerSocket.sp- The correspondingSelectorProvider.
-
-
Method Details
-
getOption
- Specified by:
getOptionin interfaceNetworkChannel- Throws:
IOException
-
setOption
- Specified by:
setOptionin interfaceNetworkChannel- Specified by:
setOptionin classServerSocketChannel- Throws:
IOException
-
supportedOptions
- Specified by:
supportedOptionsin interfaceNetworkChannel
-
bind
- Specified by:
bindin classServerSocketChannel- Throws:
IOException
-
socket
- Specified by:
socketin classServerSocketChannel
-
accept
- Specified by:
acceptin classServerSocketChannel- Throws:
IOException
-
getLocalAddress
- Specified by:
getLocalAddressin interfaceNetworkChannel- Specified by:
getLocalAddressin classServerSocketChannel
-
getLocalSocketAddress
Description copied from interface:AFSomeSocketThingReturns the socket's local socket address, ornullif unavailable or if there was a problem retrieving it.- Specified by:
getLocalSocketAddressin interfaceAFSomeSocketThing- Returns:
- The local socket address, or
null.
-
isLocalSocketAddressValid
public final boolean isLocalSocketAddressValid()Checks if the local socket address returned bygetLocalAddress()is still valid. The address is no longer valid if the server socket has been closed,null, or another server socket has been bound on that address.- Returns:
trueiff still valid.
-
implCloseSelectableChannel
- Specified by:
implCloseSelectableChannelin classAbstractSelectableChannel- Throws:
IOException
-
implConfigureBlocking
- Specified by:
implConfigureBlockingin classAbstractSelectableChannel- Throws:
IOException
-
getFileDescriptor
Description copied from interface:FileDescriptorAccessReturns the correspondingFileDescriptor.- Specified by:
getFileDescriptorin interfaceFileDescriptorAccess- Returns:
- The corresponding
FileDescriptor. - Throws:
IOException- on error.
-
isDeleteOnClose
public final boolean isDeleteOnClose()Checks if thisAFServerSocketChannel's file should be removed uponAbstractInterruptibleChannel.close(). Deletion is not guaranteed, especially when not supported (e.g., addresses in the abstract namespace).- Returns:
trueif an attempt is made to delete the socket file uponAbstractInterruptibleChannel.close().
-
setDeleteOnClose
public final void setDeleteOnClose(boolean b) Enables/disables deleting thisAFServerSocketChannel's file (or other resource type) uponAbstractInterruptibleChannel.close(). Deletion is not guaranteed, especially when not supported (e.g., addresses in the abstract namespace).- Parameters:
b- Enabled iftrue.
-
setShutdownOnClose
public void setShutdownOnClose(boolean enabled) Description copied from interface:AFSomeSocketThingConfigures whether the socket should be shutdown uponCloseable.close(), which is the default.- Specified by:
setShutdownOnClosein interfaceAFSomeSocketThing- Parameters:
enabled-trueif enabled.
-
open
Opens a server-socket channel. Thefamilyparameter specifies theprotocol familyof the channel's socket.If the
ProtocolFamilyis of anAFProtocolFamily, orUNIX, the corresponding junixsocket implementation is used. In all other cases, the call is delegated toServerSocketChannel.open().- Parameters:
family- The protocol family.- Returns:
- The new
ServerSocketChannel. - Throws:
IOException- on error.
-