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,FileDescriptorAccess
- Direct Known Subclasses:
AFUNIXServerSocketChannel
public abstract class AFServerSocketChannel<A extends AFSocketAddress>
extends ServerSocketChannel
implements FileDescriptorAccess
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 AFSocketAddress<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.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) final AFServerSocket<A>socket()final Set<SocketOption<?>>Methods inherited from class java.nio.channels.ServerSocketChannel
bind, open, 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, isOpen
-
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- Throws:
IOException
-
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.
-