- java.lang.Object
-
- java.net.ServerSocket
-
- org.newsclub.net.unix.AFUNIXServerSocket
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class AFUNIXServerSocket extends java.net.ServerSocketThe server part of an AF_UNIX domain socket.- Author:
- Christian Kohlschütter
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAFUNIXServerSocket()Constructs a new, unconnected instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AFUNIXSocketaccept()voidaddCloseable(java.io.Closeable closeable)Registers aCloseablethat should be closed when this socket is closed.voidbind(java.net.SocketAddress endpoint, int backlog)static AFUNIXServerSocketbindOn(AFUNIXSocketAddress addr)Returns a new AF_UNIXServerSocketthat is bound to the givenAFUNIXSocketAddress.voidclose()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.intgetLocalPort()java.net.SocketAddressgetLocalSocketAddress()booleanisBound()booleanisClosed()static booleanisSupported()Checks whether everything is setup to support AF_UNIX sockets.static AFUNIXServerSocketnewInstance()Returns a new, unbound AF_UNIXServerSocket.protected AFUNIXSocketnewSocketInstance()voidremoveCloseable(java.io.Closeable closeable)Unregisters a previously registeredCloseable.java.lang.StringtoString()
-
-
-
Method Detail
-
newInstance
public static AFUNIXServerSocket newInstance() throws java.io.IOException
Returns a new, unbound AF_UNIXServerSocket.- Returns:
- The new, unbound
AFUNIXServerSocket. - Throws:
java.io.IOException- if the operation fails.
-
bindOn
public static AFUNIXServerSocket bindOn(AFUNIXSocketAddress addr) throws java.io.IOException
Returns a new AF_UNIXServerSocketthat is bound to the givenAFUNIXSocketAddress.- Parameters:
addr- The socket file to bind to.- Returns:
- The new, unbound
AFUNIXServerSocket. - Throws:
java.io.IOException- if the operation fails.
-
forceBindOn
public static AFUNIXServerSocket forceBindOn(AFUNIXSocketAddress forceAddr) throws java.io.IOException
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
AFUNIXServerSocket. - Throws:
java.io.IOException- if an exception occurs.
-
bind
public void bind(java.net.SocketAddress endpoint, int backlog) throws java.io.IOException- Overrides:
bindin classjava.net.ServerSocket- Throws:
java.io.IOException
-
isBound
public boolean isBound()
- Overrides:
isBoundin classjava.net.ServerSocket
-
isClosed
public boolean isClosed()
- Overrides:
isClosedin classjava.net.ServerSocket
-
accept
public AFUNIXSocket accept() throws java.io.IOException
- Overrides:
acceptin classjava.net.ServerSocket- Throws:
java.io.IOException
-
newSocketInstance
protected AFUNIXSocket newSocketInstance() throws java.io.IOException
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.net.ServerSocket
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.net.ServerSocket- Throws:
java.io.IOException
-
addCloseable
public void addCloseable(java.io.Closeable closeable)
Registers aCloseablethat should be closed when this socket is closed.- Parameters:
closeable- The closeable.
-
removeCloseable
public void removeCloseable(java.io.Closeable closeable)
Unregisters a previously registeredCloseable.- Parameters:
closeable- The closeable.
-
isSupported
public static boolean isSupported()
Checks whether everything is setup to support AF_UNIX sockets.- Returns:
trueif supported.
-
getLocalSocketAddress
public java.net.SocketAddress getLocalSocketAddress()
- Overrides:
getLocalSocketAddressin classjava.net.ServerSocket
-
getLocalPort
public int getLocalPort()
- Overrides:
getLocalPortin classjava.net.ServerSocket
-
-