Class DomainSocketAddress

java.lang.Object
java.net.SocketAddress
java.net.InetSocketAddress
com.linecorp.armeria.common.util.DomainSocketAddress
All Implemented Interfaces:
Serializable

@UnstableApi public final class DomainSocketAddress extends InetSocketAddress
An InetSocketAddress that refers to the Path of a Unix domain socket. This class extends InetSocketAddress to ensure the backward compatibility with existing Armeria API that uses InetSocketAddress in its API. This address will have the following properties:
  • hostname and hostString - "unix:<path>", e.g. "unix:/var/run/server.sock"
  • address - an IPv6 address that falls into IPv6 Discard Prefix
See Also:
  • Method Details

    • of

      public static DomainSocketAddress of(Path path)
      Returns a newly created DomainSocketAddress with the specified Path to the Unix domain socket.
    • of

      public static DomainSocketAddress of(DomainSocketAddress nettyAddr)
      Returns a newly created DomainSocketAddress with the Path to the Unix domain socket that the specified Netty address refers to.
    • isDomainSocketAddress

      public static boolean isDomainSocketAddress(InetAddress addr)
      Returns whether the specified InetAddress matches the special IPv6 address of DomainSocketAddress. For example:
      
       DomainSocketAddress sockAddr = DomainSocketAddress.of("/var/run/server.sock");
       InetAddress inetAddr = sockAddr.getAddress();
       assert isDomainSocketAddress(inetAddr);
       
    • path

      public Path path()
      Returns the Path to the Unix domain socket.
    • authority

      public String authority()
      Returns the authority (host) form of this address which can be used as a part of URI.
    • asNettyAddress

      public DomainSocketAddress asNettyAddress()
      Converts this address to a Netty DomainSocketAddress.
      Returns:
      the converted Netty address
    • asEndpoint

      public Endpoint asEndpoint()
      Converts this address to an Endpoint.
    • toString

      public String toString()
      Returns a string representation of this address, such as "/path/to/sock".
      Overrides:
      toString in class InetSocketAddress