Class AFUNIXServerSocket
- All Implemented Interfaces:
Closeable, AutoCloseable, AFSomeSocketThing, FileDescriptorAccess
The server part of an AF_UNIX domain socket.
- Author:
- Christian Kohlschütter
-
Nested Class Summary
Nested classes/interfaces inherited from class AFServerSocket
AFServerSocket.Constructor<A>Modifier and TypeClassDescriptionstatic interfaceAFServerSocket.Constructor<A extends AFSocketAddress>The constructor of the concrete subclass. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs a new, unconnected instance. -
Method Summary
Modifier and TypeMethodDescriptionaccept()static AFUNIXServerSocketReturns a new AF_UNIXServerSocketthat is bound to the given path.static AFUNIXServerSocketReturns a new AF_UNIXServerSocketthat is bound to the given path.static AFUNIXServerSocketbindOn(AFUNIXSocketAddress addr) Returns a new AF_UNIXServerSocketthat is bound to the givenAFUNIXSocketAddress.static AFUNIXServerSocketbindOn(AFUNIXSocketAddress addr, boolean deleteOnClose) Returns a new AF_UNIXServerSocketthat is bound to the givenAFSocketAddress.static AFUNIXServerSocketforceBindOn(AFUNIXSocketAddress forceAddr) Returns a new, unbound AF_UNIXServerSocketthat will always bind to the given address, regardless of any socket address used in a call tobind.protected AFUNIXServerSocketChannelCreates a new AFServerSocketChannel for this socket.protected AFSocketImpl<AFUNIXSocketAddress> newImpl(FileDescriptor fdObj) Creates a new AFSocketImpl.static AFUNIXServerSocketReturns a new, unbound AF_UNIXServerSocket.protected AFUNIXSocketReturns a newAFSocketinstance.Methods inherited from class AFServerSocket
addCloseable, addressFamily, bind, bind, bindHook, bindOn, bindOn, close, forceBindAddress, forceBindOn, getFileDescriptor, getInetAddress, getLocalPort, getLocalSocketAddress, getOption, getReceiveBufferSize, getReuseAddress, getSoTimeout, isBound, isClosed, isDeleteOnClose, isLocalSocketAddressValid, isSupported, newInstance, newInstance, removeCloseable, setDeleteOnClose, setOption, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setShutdownOnClose, setSoTimeout, supportedOptions, toStringModifier and TypeMethodDescriptionfinal voidaddCloseable(Closeable closeable) Registers aCloseablethat should be closed when this socket is closed.protected final AFAddressFamily<AFUNIXSocketAddress> Returns the address family supported by this implementation.final voidbind(SocketAddress endpoint) final voidbind(SocketAddress endpoint, int backlog) bindHook(SocketAddressFilter hook) Sets the hook for any subsequent call toAFServerSocket.bind(SocketAddress)andAFServerSocket.bind(SocketAddress, int)to be the given function.protected static <A extends AFSocketAddress>
AFServerSocket<A> bindOn(AFServerSocket.Constructor<A> instanceSupplier, A addr, boolean deleteOnClose) Returns a newServerSocketthat is bound to the givenAFSocketAddress.protected static <A extends AFSocketAddress>
AFServerSocket<A> bindOn(AFServerSocket.Constructor<A> instanceSupplier, AFSocketAddress addr) Returns a newServerSocketthat is bound to the givenAFSocketAddress.voidclose()forceBindAddress(SocketAddress endpoint) Forces the address to be used for any subsequent call toAFServerSocket.bind(SocketAddress)to be the given one, regardless of what'll be passed toAFServerSocket.bind(SocketAddress, int), but doesn't bind yet.protected static <A extends AFSocketAddress>
AFServerSocket<A> forceBindOn(AFServerSocket.Constructor<A> instanceSupplier, A forceAddr) Returns a new, unboundServerSocketthat will always bind to the given address, regardless of any socket address used in a call tobind.final FileDescriptorReturns the correspondingFileDescriptor.final intfinal AFUNIXSocketAddressReturns the socket's local socket address, ornullif unavailable or if there was a problem retrieving it.<T> TgetOption(SocketOption<T> name) intbooleanintfinal booleanisBound()final booleanisClosed()final booleanChecks if thisAFServerSocket's file should be removed uponAFServerSocket.close().booleanChecks if the local socket address returned byAFServerSocket.getLocalSocketAddress()is still valid.static booleanChecks whether everything is setup to support junixsocket sockets.protected static <A extends AFSocketAddress>
AFServerSocket<A> newInstance(AFServerSocket.Constructor<A> instanceSupplier) Creates a new AFServerSocket instance, using the given subclass constructor.protected static <A extends AFSocketAddress>
AFServerSocket<A> newInstance(AFServerSocket.Constructor<A> instanceSupplier, FileDescriptor fdObj, int localPort, int remotePort) Creates a new AFServerSocket instance, using the given subclass constructor.final voidremoveCloseable(Closeable closeable) Unregisters a previously registeredCloseable.final voidsetDeleteOnClose(boolean b) Enables/disables deleting thisAFServerSocket's file (or other resource type) uponAFServerSocket.close().<T> ServerSocketsetOption(SocketOption<T> name, T value) voidsetPerformancePreferences(int connectionTime, int latency, int bandwidth) voidsetReceiveBufferSize(int size) voidsetReuseAddress(boolean on) voidsetShutdownOnClose(boolean enabled) Configures whether the socket should be shutdown uponCloseable.close(), which is the default.voidsetSoTimeout(int timeout) Set<SocketOption<?>> toString()Methods inherited from class ServerSocket
implAccept, setSocketFactory
-
Constructor Details
-
AFUNIXServerSocket
Constructs a new, unconnected instance.- Throws:
IOException- if the operation fails.
-
-
Method Details
-
newChannel
Description copied from class:AFServerSocketCreates a new AFServerSocketChannel for this socket.- Specified by:
newChannelin classAFServerSocket<AFUNIXSocketAddress>- Returns:
- The new instance.
-
getChannel
- Overrides:
getChannelin classAFServerSocket<AFUNIXSocketAddress>
-
newInstance
Returns a new, unbound AF_UNIXServerSocket.- Returns:
- The new, unbound
AFServerSocket. - Throws:
IOException- if the operation fails.
-
bindOn
Returns a new AF_UNIXServerSocketthat is bound to the givenAFUNIXSocketAddress.- Parameters:
addr- The socket file to bind to.- Returns:
- The new, bound
AFServerSocket. - Throws:
IOException- if the operation fails.
-
bindOn
public static AFUNIXServerSocket bindOn(AFUNIXSocketAddress addr, boolean deleteOnClose) throws IOException Returns a new AF_UNIXServerSocketthat is bound to the givenAFSocketAddress.- Parameters:
addr- The socket file to bind to.deleteOnClose- Iftrue, the socket file (if the address points to a file) will be deleted uponAFServerSocket.close().- Returns:
- The new, bound
AFServerSocket. - Throws:
IOException- if the operation fails.
-
bindOn
Returns a new AF_UNIXServerSocketthat is bound to the given path.- Parameters:
path- The path to bind to.deleteOnClose- Iftrue, the socket file will be deleted uponAFServerSocket.close().- Returns:
- The new, bound
AFServerSocket. - Throws:
IOException- if the operation fails.
-
bindOn
Returns a new AF_UNIXServerSocketthat is bound to the given path.- Parameters:
path- The path to bind to.deleteOnClose- Iftrue, the socket file will be deleted uponAFServerSocket.close().- Returns:
- The new, bound
AFServerSocket. - Throws:
IOException- if the operation fails.
-
forceBindOn
Returns a new, unbound AF_UNIXServerSocketthat will always bind to the given address, regardless of any socket address used in a call tobind.- Parameters:
forceAddr- The address to use.- Returns:
- The new, yet unbound
AFServerSocket. - Throws:
IOException- if an exception occurs.
-
newImpl
Description copied from class:AFServerSocketCreates a new AFSocketImpl.- Specified by:
newImplin classAFServerSocket<AFUNIXSocketAddress>- Parameters:
fdObj- The file descriptor.- Returns:
- The new instance.
- Throws:
SocketException
-
newSocketInstance
Returns a newAFSocketinstance.- Specified by:
newSocketInstancein classAFServerSocket<AFUNIXSocketAddress>- Returns:
- The new instance.
- Throws:
IOException- on error.
-
accept
- Overrides:
acceptin classAFServerSocket<AFUNIXSocketAddress>- Throws:
IOException
-