Top Description Fields Constructors Methods
org.newsclub.net.unix

public abstract Class AFServerSocketChannel<A extends AFSocketAddress>

extends ServerSocketChannel
implements FileDescriptorAccess, AFSomeSocketChannel
Class Inheritance
All Implemented Interfaces
org.newsclub.net.unix.AFSomeSocketChannel, org.newsclub.net.unix.AFSomeSocketThing, org.newsclub.net.unix.FileDescriptorAccess, java.io.Closeable, java.lang.AutoCloseable, java.nio.channels.InterruptibleChannel, java.nio.channels.Channel
Known Direct Subclasses
org.newsclub.net.unix.AFUNIXServerSocketChannel, org.newsclub.net.unix.AFGenericServerSocketChannel
Type Parameters
<A>
The concrete AFSocketAddress that is supported by this type.
Static Imports
java.util.Objects.requireNonNull

A selectable channel for stream-oriented listening sockets.
Author
Christian Kohlschütter

Field Summary

Modifier and TypeField and Description
private final @NonNull AFServerSocket<A>

Constructor Summary

AccessConstructor and Description
protected
AFServerSocketChannel(AFServerSocket<A>
The corresponding ServerSocket.
socket
,
AFSelectorProvider<A>
The corresponding SelectorProvider.
sp
)

Creates a new AFServerSocketChannel instance.

Method Summary

Modifier and TypeMethod and Description
public AFSocketChannel<A>
accept()

Implements abstract java.nio.channels.ServerSocketChannel.accept.

Accepts a connection made to this channel's socket.

public final AFServerSocketChannel<A>
bind(SocketAddress
The address to bind the socket, or null to bind to an automatically assigned socket address
local
,
int
The maximum number of pending connections
backlog
)

Implements abstract java.nio.channels.ServerSocketChannel.bind.

Binds the channel's socket to a local address and configures the socket to listen for connections.

pack-priv final AFSocketCore
public final FileDescriptor
public final @Nullable A
getLocalAddress()

Implements abstract java.nio.channels.ServerSocketChannel.getLocalAddress.

Implements java.nio.channels.NetworkChannel.getLocalAddress.

Returns the socket address that this channel's socket is bound to.

public final @Nullable A
getLocalSocketAddress()

Implements org.newsclub.net.unix.AFSomeSocketThing.getLocalSocketAddress.

Returns the socket's local socket address, or null if unavailable or if there was a problem retrieving it.

public <T> T
getOption(SocketOption<T>
The socket option
name
)

Implements java.nio.channels.NetworkChannel.getOption.

Returns the value of a socket option.

protected final void
protected final void
implConfigureBlocking(boolean
If true then this channel will be placed in blocking mode; if false then it will be placed non-blocking mode
block
)

Implements abstract java.nio.channels.spi.AbstractSelectableChannel.implConfigureBlocking.

Adjusts this channel's blocking mode.

public final boolean

Returns:

true if an attempt is made to delete the socket file upon close().
isDeleteOnClose
()

Checks if this AFServerSocketChannel's file should be removed upon close().

public final boolean

Returns:

true iff still valid.
isLocalSocketAddressValid
()

Checks if the local socket address returned by getLocalAddress() is still valid.

public static ServerSocketChannel

Returns:

The new ServerSocketChannel.
open
(ProtocolFamily
The protocol family.
family
)

Hides java.nio.channels.ServerSocketChannel.open.

Opens a server-socket channel.

public final void
setDeleteOnClose(boolean
Enabled if true.
b
)

Enables/disables deleting this AFServerSocketChannel's file (or other resource type) upon close().

public <T> AFServerSocketChannel<A>
setOption(SocketOption<T>
The socket option
name
,
T
The value of the socket option. A value of null may be a valid value for some socket options.
value
)

Implements abstract java.nio.channels.ServerSocketChannel.setOption.

Implements java.nio.channels.NetworkChannel.setOption.

Sets the value of a socket option.

public void
setShutdownOnClose(boolean
true if enabled.
enabled
)

Implements org.newsclub.net.unix.AFSomeSocketThing.setShutdownOnClose.

Configures whether the socket should be shutdown upon close(), which is the default.

public final AFServerSocket<A>
socket()

Implements abstract java.nio.channels.ServerSocketChannel.socket.

Retrieves a server socket associated with this channel.

public final Set<SocketOption<?>>
supportedOptions()

Implements java.nio.channels.NetworkChannel.supportedOptions.

Returns a set of the socket options supported by this channel.

Inherited from java.nio.channels.ServerSocketChannel:
bindopenvalidOps

Field Detail

afSocketback to summary
private final @NonNull AFServerSocket<A> afSocket

Constructor Detail

AFServerSocketChannelback to summary
protected AFServerSocketChannel(AFServerSocket<A> socket, AFSelectorProvider<A> sp)

Creates a new AFServerSocketChannel instance.

Parameters
socket:AFServerSocket<A>

The corresponding ServerSocket.

sp:AFSelectorProvider<A>

The corresponding SelectorProvider.

Annotations
@SuppressWarnings:all

Method Detail

acceptback to summary
public AFSocketChannel<A> accept() throws IOException

Implements abstract java.nio.channels.ServerSocketChannel.accept.

Doc from java.nio.channels.ServerSocketChannel.accept.

Accepts a connection made to this channel's socket.

If this channel is in non-blocking mode then this method will immediately return null if there are no pending connections. Otherwise it will block indefinitely until a new connection is available or an I/O error occurs.

The socket channel returned by this method, if any, will be in blocking mode regardless of the blocking mode of this channel.

Returns:AFSocketChannel<A>

The socket channel for the new connection, or null if this channel is in non-blocking mode and no connection is available to be accepted

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
bindback to summary
public final AFServerSocketChannel<A> bind(SocketAddress local, int backlog) throws IOException

Implements abstract java.nio.channels.ServerSocketChannel.bind.

Doc from java.nio.channels.ServerSocketChannel.bind.

Binds the channel's socket to a local address and configures the socket to listen for connections.

This method is used to establish an association between the socket and a local address. For Internet protocol sockets, once an association is established then the socket remains bound until the channel is closed.

The backlog parameter is the maximum number of pending connections on the socket. Its exact semantics are implementation specific. In particular, an implementation may impose a maximum length or may choose to ignore the parameter altogether. If the backlog parameter has the value 0, or a negative value, then an implementation specific default is used.

Parameters
local:SocketAddress

The address to bind the socket, or null to bind to an automatically assigned socket address

backlog:int

The maximum number of pending connections

Returns:AFServerSocketChannel<A>

This channel

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
getAFCoreback to summary
pack-priv final AFSocketCore getAFCore()
getFileDescriptorback to summary
public final FileDescriptor getFileDescriptor() throws IOException

Implements org.newsclub.net.unix.FileDescriptorAccess.getFileDescriptor.

Doc from org.newsclub.net.unix.FileDescriptorAccess.getFileDescriptor.

Returns the corresponding FileDescriptor.

Returns:FileDescriptor

The corresponding FileDescriptor.

Annotations
@Override
Exceptions
IOException:
on error.
getLocalAddressback to summary
public final @Nullable A getLocalAddress()

Implements abstract java.nio.channels.ServerSocketChannel.getLocalAddress.

Implements java.nio.channels.NetworkChannel.getLocalAddress.

Doc from java.nio.channels.ServerSocketChannel.getLocalAddress.

Returns the socket address that this channel's socket is bound to.

Where the channel is bound to an Internet Protocol socket address then the return value from this method is of type java.net.InetSocketAddress.

Where the channel is bound to a Unix Domain socket address, the socket address is a UnixDomainSocketAddress.

Returns:@Nullable A

The SocketAddress that the socket is bound to or null if the channel's socket is not bound

Annotations
@Override
getLocalSocketAddressback to summary
public final @Nullable A getLocalSocketAddress()

Implements org.newsclub.net.unix.AFSomeSocketThing.getLocalSocketAddress.

Doc from org.newsclub.net.unix.AFSomeSocketThing.getLocalSocketAddress.

Returns the socket's local socket address, or null if unavailable or if there was a problem retrieving it.

Returns:@Nullable A

The local socket address, or null.

Annotations
@Override
getOptionback to summary
public <T> T getOption(SocketOption<T> name) throws IOException

Implements java.nio.channels.NetworkChannel.getOption.

Doc from java.nio.channels.NetworkChannel.getOption.

Returns the value of a socket option.

Parameters
<T>
The type of the socket option value
name:SocketOption<T>

The socket option

Returns:T

The value of the socket option. A value of null may be a valid value for some socket options.

Annotations
@SuppressWarnings:unchecked
@Override
Exceptions
IOException:
If an I/O error occurs
implCloseSelectableChannelback to summary
protected final void implCloseSelectableChannel() throws IOException

Implements abstract java.nio.channels.spi.AbstractSelectableChannel.implCloseSelectableChannel.

Doc from java.nio.channels.spi.AbstractSelectableChannel.implCloseSelectableChannel.

Closes this selectable channel.

This method is invoked by the close method in order to perform the actual work of closing the channel. This method is only invoked if the channel has not yet been closed, and it is never invoked more than once.

An implementation of this method must arrange for any other thread that is blocked in an I/O operation upon this channel to return immediately, either by throwing an exception or by returning normally.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
implConfigureBlockingback to summary
protected final void implConfigureBlocking(boolean block) throws IOException

Implements abstract java.nio.channels.spi.AbstractSelectableChannel.implConfigureBlocking.

Doc from java.nio.channels.spi.AbstractSelectableChannel.implConfigureBlocking.

Adjusts this channel's blocking mode.

This method is invoked by the configureBlocking method in order to perform the actual work of changing the blocking mode. This method is only invoked if the new mode is different from the current mode.

Parameters
block:boolean

If true then this channel will be placed in blocking mode; if false then it will be placed non-blocking mode

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
isDeleteOnCloseback to summary
public final boolean isDeleteOnClose()

Checks if this AFServerSocketChannel's file should be removed upon close(). Deletion is not guaranteed, especially when not supported (e.g., addresses in the abstract namespace).

Returns:boolean

true if an attempt is made to delete the socket file upon close().

isLocalSocketAddressValidback to summary
public final boolean isLocalSocketAddressValid()

Checks if the local socket address returned by getLocalAddress() 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:boolean

true iff still valid.

openback to summary
public static ServerSocketChannel open(ProtocolFamily family) throws IOException

Hides java.nio.channels.ServerSocketChannel.open.

Opens a server-socket channel. The family parameter specifies the protocol family of the channel's socket.

If the ProtocolFamily is of an AFProtocolFamily, or UNIX, the corresponding junixsocket implementation is used. In all other cases, the call is delegated to ServerSocketChannel#open().

Parameters
family:ProtocolFamily

The protocol family.

Returns:ServerSocketChannel

The new ServerSocketChannel.

Exceptions
IOException:
on error.
setDeleteOnCloseback to summary
public final void setDeleteOnClose(boolean b)

Enables/disables deleting this AFServerSocketChannel's file (or other resource type) upon close(). Deletion is not guaranteed, especially when not supported (e.g., addresses in the abstract namespace).

Parameters
b:boolean

Enabled if true.

setOptionback to summary
public <T> AFServerSocketChannel<A> setOption(SocketOption<T> name, T value) throws IOException

Implements abstract java.nio.channels.ServerSocketChannel.setOption.

Implements java.nio.channels.NetworkChannel.setOption.

Doc from java.nio.channels.NetworkChannel.setOption.

Sets the value of a socket option.

Parameters
<T>
The type of the socket option value
name:SocketOption<T>

The socket option

value:T

The value of the socket option. A value of null may be a valid value for some socket options.

Returns:AFServerSocketChannel<A>

This channel

Annotations
@Override
Exceptions
IOException:

Doc from java.nio.channels.ServerSocketChannel.setOption.

If an I/O error occurs

setShutdownOnCloseback to summary
public void setShutdownOnClose(boolean enabled)

Implements org.newsclub.net.unix.AFSomeSocketThing.setShutdownOnClose.

Doc from org.newsclub.net.unix.AFSomeSocketThing.setShutdownOnClose.

Configures whether the socket should be shutdown upon close(), which is the default.

Parameters
enabled:boolean

true if enabled.

Annotations
@Override
socketback to summary
public final AFServerSocket<A> socket()

Implements abstract java.nio.channels.ServerSocketChannel.socket.

Doc from java.nio.channels.ServerSocketChannel.socket.

Retrieves a server socket associated with this channel.

The returned object will not declare any public methods that are not declared in the java.net.ServerSocket class.

Returns:AFServerSocket<A>

A server socket associated with this channel

Annotations
@SuppressFBWarnings:EI_EXPOSE_REP
@Override
supportedOptionsback to summary
public final Set<SocketOption<?>> supportedOptions()

Implements java.nio.channels.NetworkChannel.supportedOptions.

Doc from java.nio.channels.NetworkChannel.supportedOptions.

Returns a set of the socket options supported by this channel.

This method will continue to return the set of options even after the channel has been closed.

Returns:Set<SocketOption<?>>

A set of the socket options supported by this channel

Annotations
@Override