- java.lang.Object
-
- java.net.SocketAddress
-
- java.net.InetSocketAddress
-
- org.newsclub.net.unix.AFUNIXSocketAddress
-
- All Implemented Interfaces:
java.io.Serializable
public final class AFUNIXSocketAddress extends java.net.InetSocketAddressDescribes anInetSocketAddressthat actually uses AF_UNIX sockets instead of AF_INET. The ability to specify a port number is not specified by AF_UNIX sockets, but we need it sometimes, for example for RMI-over-AF_UNIX.- Author:
- Christian Kohlschütter
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AFUNIXSocketAddress(byte[] socketAddress)Creates a newAFUNIXSocketAddressthat points to the AF_UNIX socket specified by the given byte sequence.AFUNIXSocketAddress(byte[] socketAddress, int port)Creates a newAFUNIXSocketAddressthat points to the AF_UNIX socket specified by the given byte sequence, assigning the given port to it.AFUNIXSocketAddress(java.io.File socketFile)Creates a newAFUNIXSocketAddressthat points to the AF_UNIX socket specified by the given file.AFUNIXSocketAddress(java.io.File socketFile, int port)Creates a newAFUNIXSocketAddressthat points to the AF_UNIX socket specified by the given file, assigning the given port to it.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetPath()Returns the path to the UNIX domain socket, as a human-readable string.byte[]getPathAsBytes()Returns the path to the UNIX domain socket, as bytes.static AFUNIXSocketAddressinAbstractNamespace(java.lang.String name)Convenience method to create anAFUNIXSocketAddressin the abstract namespace.static AFUNIXSocketAddressinAbstractNamespace(java.lang.String name, int port)Convenience method to create anAFUNIXSocketAddressin the abstract namespace.java.lang.StringtoString()
-
-
-
Constructor Detail
-
AFUNIXSocketAddress
public AFUNIXSocketAddress(java.io.File socketFile) throws java.io.IOExceptionCreates a newAFUNIXSocketAddressthat points to the AF_UNIX socket specified by the given file.- Parameters:
socketFile- The socket to connect to.- Throws:
java.io.IOException- if the operation fails.
-
AFUNIXSocketAddress
public AFUNIXSocketAddress(java.io.File socketFile, int port) throws java.io.IOExceptionCreates a newAFUNIXSocketAddressthat points to the AF_UNIX socket specified by the given file, assigning the given port to it.- Parameters:
socketFile- The socket to connect to.port- The port associated with this socket, or0when no port should be assigned.- Throws:
java.io.IOException- if the operation fails.
-
AFUNIXSocketAddress
public AFUNIXSocketAddress(byte[] socketAddress) throws java.io.IOExceptionCreates a newAFUNIXSocketAddressthat points to the AF_UNIX socket specified by the given byte sequence. NOTE: By specifying a byte array that starts with a zero byte, you indicate that the abstract namespace is to be used. This feature is not available on all target platforms.- Parameters:
socketAddress- The socket address (as bytes).- Throws:
java.io.IOException- if the operation fails.- See Also:
inAbstractNamespace(String)
-
AFUNIXSocketAddress
public AFUNIXSocketAddress(byte[] socketAddress, int port) throws java.io.IOExceptionCreates a newAFUNIXSocketAddressthat points to the AF_UNIX socket specified by the given byte sequence, assigning the given port to it. NOTE: By specifying a byte array that starts with a zero byte, you indicate that the abstract namespace is to be used. This feature is not available on all target platforms.- Parameters:
socketAddress- The socket address (as bytes).port- The port associated with this socket, or0when no port should be assigned.- Throws:
java.io.IOException- if the operation fails.- See Also:
inAbstractNamespace(String,int)
-
-
Method Detail
-
inAbstractNamespace
public static AFUNIXSocketAddress inAbstractNamespace(java.lang.String name) throws java.io.IOException
Convenience method to create anAFUNIXSocketAddressin the abstract namespace. The returned socket address will use the byte representation of this identifier (using the system's default character encoding), prefixed with a null byte (to indicate the abstract namespace is used).- Parameters:
name- The identifier in the abstract namespace, without trailing zero or @.- Returns:
- The address.
- Throws:
java.io.IOException- if the operation fails.
-
inAbstractNamespace
public static AFUNIXSocketAddress inAbstractNamespace(java.lang.String name, int port) throws java.io.IOException
Convenience method to create anAFUNIXSocketAddressin the abstract namespace. The returned socket address will use the byte representation of this identifier (using the system's default character encoding), prefixed with a null byte (to indicate the abstract namespace is used).- Parameters:
name- The identifier in the abstract namespace, without trailing zero or @.port- The port associated with this socket, or0when no port should be assigned.- Returns:
- The address.
- Throws:
java.io.IOException- if the operation fails.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.net.InetSocketAddress
-
getPath
public java.lang.String getPath()
Returns the path to the UNIX domain socket, as a human-readable string. Zero-bytes are converted to '@', other non-printable bytes are converted to '.'- Returns:
- The path.
- See Also:
getPathAsBytes()
-
getPathAsBytes
public byte[] getPathAsBytes()
Returns the path to the UNIX domain socket, as bytes.- Returns:
- The path.
- See Also:
getPath()
-
-