Class AFUNIXSocketAddress

  • All Implemented Interfaces:
    java.io.Serializable

    public final class AFUNIXSocketAddress
    extends java.net.InetSocketAddress
    Describes an InetSocketAddress that 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 Detail

      • AFUNIXSocketAddress

        public AFUNIXSocketAddress​(java.io.File socketFile)
                            throws java.io.IOException
        Creates a new AFUNIXSocketAddress that 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.IOException
        Creates a new AFUNIXSocketAddress that 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, or 0 when no port should be assigned.
        Throws:
        java.io.IOException - if the operation fails.
      • AFUNIXSocketAddress

        public AFUNIXSocketAddress​(byte[] socketAddress)
                            throws java.io.IOException
        Creates a new AFUNIXSocketAddress that 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.IOException
        Creates a new AFUNIXSocketAddress that 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, or 0 when 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 an AFUNIXSocketAddress in 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 an AFUNIXSocketAddress in 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, or 0 when no port should be assigned.
        Returns:
        The address.
        Throws:
        java.io.IOException - if the operation fails.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.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()