Top Description Constructors Methods
org.newsclub.net.unix

public final Class AFUNIXServerSocket

extends AFServerSocket<AFUNIXSocketAddress>
Class Inheritance
Imports
java.io.File, .FileDescriptor, .IOException, java.net.ServerSocket, .SocketException, java.nio.file.Path

The server part of an AF_UNIX domain socket.
Author
Christian Kohlschütter

Constructor Summary

AccessConstructor and Description
protected
AFUNIXServerSocket()

Constructs a new, unconnected instance.

pack-priv
AFUNIXServerSocket(FileDescriptor
The file descriptor, or null.
fdObj
)

Constructs a new instance, optionally associated with the given file descriptor.

Method Summary

Modifier and TypeMethod and Description
public AFUNIXSocket
accept()

Overrides org.newsclub.net.unix.AFServerSocket.accept.

Listens for a connection to be made to this socket and accepts it.

public static AFUNIXServerSocket

Returns:

The new, bound AFServerSocket.
bindOn
(final AFUNIXSocketAddress
The socket file to bind to.
addr
)

Returns a new AF_UNIX ServerSocket that is bound to the given AFUNIXSocketAddress.

public static AFUNIXServerSocket

Returns:

The new, bound AFServerSocket.
bindOn
(final AFUNIXSocketAddress
The socket file to bind to.
addr
,
boolean
If true, the socket file (if the address points to a file) will be deleted upon close.
deleteOnClose
)

Returns a new AF_UNIX ServerSocket that is bound to the given AFSocketAddress.

public static AFUNIXServerSocket

Returns:

The new, bound AFServerSocket.
bindOn
(final File
The path to bind to.
path
,
boolean
If true, the socket file will be deleted upon close.
deleteOnClose
)

Returns a new AF_UNIX ServerSocket that is bound to the given path.

public static AFUNIXServerSocket

Returns:

The new, bound AFServerSocket.
bindOn
(final Path
The path to bind to.
path
,
boolean
If true, the socket file will be deleted upon close.
deleteOnClose
)

Returns a new AF_UNIX ServerSocket that is bound to the given path.

public static AFUNIXServerSocket

Returns:

The new, yet unbound AFServerSocket.
forceBindOn
(final AFUNIXSocketAddress
The address to use.
forceAddr
)

Returns a new, unbound AF_UNIX ServerSocket that will always bind to the given address, regardless of any socket address used in a call to bind.

public AFUNIXServerSocketChannel
getChannel()

Overrides org.newsclub.net.unix.AFServerSocket.getChannel.

Returns the unique java.nio.channels.ServerSocketChannel object associated with this socket, if any.

protected AFUNIXServerSocketChannel
newChannel()

Implements abstract org.newsclub.net.unix.AFServerSocket.newChannel.

Creates a new AFServerSocketChannel for this socket.

protected AFSocketImpl<AFUNIXSocketAddress>
newImpl(FileDescriptor
The file descriptor.
fdObj
)

Implements abstract org.newsclub.net.unix.AFServerSocket.newImpl.

Creates a new AFSocketImpl.

public static AFUNIXServerSocket

Returns:

The new, unbound AFServerSocket.
newInstance
()

Returns a new, unbound AF_UNIX ServerSocket.

pack-priv static AFUNIXServerSocket
newInstance(FileDescriptor fdObj, int localPort, int remotePort)

protected AFUNIXSocket

Returns:

The new instance.
newSocketInstance
()

Implements abstract org.newsclub.net.unix.AFServerSocket.newSocketInstance.

Returns a new AFSocket instance.

Inherited from org.newsclub.net.unix.AFServerSocket:
accept1addCloseableaddressFamilybindbindbindHookbindOnbindOncloseforceBindAddressforceBindOngetAFImplgetFileDescriptorgetInetAddressgetLocalPortgetLocalSocketAddressgetOptiongetReceiveBufferSizegetReuseAddressgetSoTimeoutisBoundisClosedisDeleteOnCloseisLocalSocketAddressValidisSupportednewInstancenewInstanceremoveCloseablesetBoundEndpointsetDeleteOnClosesetOptionsetPerformancePreferencessetReceiveBufferSizesetReuseAddresssetShutdownOnClosesetSoTimeoutsupportedOptionstoString

Constructor Detail

AFUNIXServerSocketback to summary
protected AFUNIXServerSocket() throws IOException

Constructs a new, unconnected instance.

Exceptions
IOException:
if the operation fails.
AFUNIXServerSocketback to summary
pack-priv AFUNIXServerSocket(FileDescriptor fdObj) throws IOException

Constructs a new instance, optionally associated with the given file descriptor.

Parameters
fdObj:FileDescriptor

The file descriptor, or null.

Exceptions
IOException:
if the operation fails.

Method Detail

acceptback to summary
public AFUNIXSocket accept() throws IOException

Overrides org.newsclub.net.unix.AFServerSocket.accept.

Doc from java.net.ServerSocket.accept.

Listens for a connection to be made to this socket and accepts it. The method blocks until a connection is made.

This method is interruptible in the following circumstances:

  1. The socket is associated with a ServerSocketChannel. In that case, interrupting a thread accepting a connection will close the underlying channel and cause this method to throw java.nio.channels.ClosedByInterruptException with the interrupt status set.
  2. The socket uses the system-default socket implementation and a virtual thread is accepting a connection. In that case, interrupting the virtual thread will cause it to wakeup and close the socket. This method will then throw SocketException with the interrupt status set.
Returns:AFUNIXSocket

the new Socket

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when waiting for a connection, the socket is not bound or the socket is closed.
bindOnback to summary
public static AFUNIXServerSocket bindOn(final AFUNIXSocketAddress addr) throws IOException

Returns a new AF_UNIX ServerSocket that is bound to the given AFUNIXSocketAddress.

Parameters
addr:AFUNIXSocketAddress

The socket file to bind to.

Returns:AFUNIXServerSocket

The new, bound AFServerSocket.

Exceptions
IOException:
if the operation fails.
bindOnback to summary
public static AFUNIXServerSocket bindOn(final AFUNIXSocketAddress addr, boolean deleteOnClose) throws IOException

Returns a new AF_UNIX ServerSocket that is bound to the given AFSocketAddress.

Parameters
addr:AFUNIXSocketAddress

The socket file to bind to.

deleteOnClose:boolean

If true, the socket file (if the address points to a file) will be deleted upon close.

Returns:AFUNIXServerSocket

The new, bound AFServerSocket.

Exceptions
IOException:
if the operation fails.
bindOnback to summary
public static AFUNIXServerSocket bindOn(final File path, boolean deleteOnClose) throws IOException

Returns a new AF_UNIX ServerSocket that is bound to the given path.

Parameters
path:File

The path to bind to.

deleteOnClose:boolean

If true, the socket file will be deleted upon close.

Returns:AFUNIXServerSocket

The new, bound AFServerSocket.

Exceptions
IOException:
if the operation fails.
bindOnback to summary
public static AFUNIXServerSocket bindOn(final Path path, boolean deleteOnClose) throws IOException

Returns a new AF_UNIX ServerSocket that is bound to the given path.

Parameters
path:Path

The path to bind to.

deleteOnClose:boolean

If true, the socket file will be deleted upon close.

Returns:AFUNIXServerSocket

The new, bound AFServerSocket.

Exceptions
IOException:
if the operation fails.
forceBindOnback to summary
public static AFUNIXServerSocket forceBindOn(final AFUNIXSocketAddress forceAddr) throws IOException

Returns a new, unbound AF_UNIX ServerSocket that will always bind to the given address, regardless of any socket address used in a call to bind.

Parameters
forceAddr:AFUNIXSocketAddress

The address to use.

Returns:AFUNIXServerSocket

The new, yet unbound AFServerSocket.

Exceptions
IOException:
if an exception occurs.
getChannelback to summary
public AFUNIXServerSocketChannel getChannel()

Overrides org.newsclub.net.unix.AFServerSocket.getChannel.

Doc from java.net.ServerSocket.getChannel.

Returns the unique java.nio.channels.ServerSocketChannel object associated with this socket, if any.

A server socket will have a channel if, and only if, the channel itself was created via the ServerSocketChannel.open method.

Returns:AFUNIXServerSocketChannel

the server-socket channel associated with this socket, or null if this socket was not created for a channel

Annotations
@Override
newChannelback to summary
protected AFUNIXServerSocketChannel newChannel()

Implements abstract org.newsclub.net.unix.AFServerSocket.newChannel.

Doc from org.newsclub.net.unix.AFServerSocket.newChannel.

Creates a new AFServerSocketChannel for this socket.

Returns:AFUNIXServerSocketChannel

The new instance.

Annotations
@Override
newImplback to summary
protected AFSocketImpl<AFUNIXSocketAddress> newImpl(FileDescriptor fdObj) throws SocketException

Implements abstract org.newsclub.net.unix.AFServerSocket.newImpl.

Doc from org.newsclub.net.unix.AFServerSocket.newImpl.

Creates a new AFSocketImpl.

Parameters
fdObj:FileDescriptor

The file descriptor.

Returns:AFSocketImpl<AFUNIXSocketAddress>

The new instance.

Annotations
@Override
newInstanceback to summary
public static AFUNIXServerSocket newInstance() throws IOException

Returns a new, unbound AF_UNIX ServerSocket.

Returns:AFUNIXServerSocket

The new, unbound AFServerSocket.

Exceptions
IOException:
if the operation fails.
newInstanceback to summary
pack-priv static AFUNIXServerSocket newInstance(FileDescriptor fdObj, int localPort, int remotePort) throws IOException
newSocketInstanceback to summary
protected AFUNIXSocket newSocketInstance() throws IOException

Implements abstract org.newsclub.net.unix.AFServerSocket.newSocketInstance.

Returns a new AFSocket instance.

Returns:AFUNIXSocket

The new instance.

Annotations
@Override
Exceptions
IOException:
on error.