NetworkHostAndPort
Keywords: net.corda.core.utilities.NetworkHostAndPort class
Date: 2023-09-18

net.corda.core.utilities

## Class NetworkHostAndPort

- net.corda.core.utilities.NetworkHostAndPort

-     public class NetworkHostAndPort

  Tuple of host and port. Use `NetworkHostAndPort.parse` on untrusted data.

  See Also:
    `NetworkHostAndPort.parse`

- - ### Field Detail

    - #### Companion

          public static net.corda.core.utilities.NetworkHostAndPort.Companion Companion

  - ### Constructor Detail

    - #### NetworkHostAndPort

          public NetworkHostAndPort(@NotNull
                                    java.lang.String host,
                                    int port)

      Tuple of host and port. Use `NetworkHostAndPort.parse` on untrusted data.

      Parameters:
        `host` - a hostname or IP address. IPv6 addresses must not be enclosed in square brackets.
        `port` - a valid port number.
      See Also:
        `NetworkHostAndPort.parse`

  - ### Method Detail

    - #### toString

          @NotNull
          public java.lang.String toString()

    - #### getHost

          @NotNull
          public java.lang.String getHost()

      a hostname or IP address.

      IPv6 addresses must not be enclosed in square brackets.

    - #### getPort

          public int getPort()

      a valid port number.

    - #### component1

          @NotNull
          public java.lang.String component1()

      a hostname or IP address.

      IPv6 addresses must not be enclosed in square brackets.

    - #### component2

          public int component2()

      a valid port number.

    - #### copy

          @NotNull
          public NetworkHostAndPort copy(@NotNull
                                                  java.lang.String host,
                                                  int port)

      Tuple of host and port. Use `NetworkHostAndPort.parse` on untrusted data.

      Parameters:
        `host` - a hostname or IP address. IPv6 addresses must not be enclosed in square brackets.
        `port` - a valid port number.
      See Also:
        `NetworkHostAndPort.parse`

    - #### hashCode

          public int hashCode()

      Tuple of host and port. Use `NetworkHostAndPort.parse` on untrusted data.

      See Also:
        `NetworkHostAndPort.parse`

    - #### equals

          public boolean equals(@Nullable
                                java.lang.Object p)

      Tuple of host and port. Use `NetworkHostAndPort.parse` on untrusted data.

      See Also:
        `NetworkHostAndPort.parse`

    - #### parse

          @JvmStatic
           @NotNull
          public static NetworkHostAndPort parse(@NotNull
                                                                      java.lang.String str)

      Parses a string of the form host:port into a `class NetworkHostAndPort`. The host part may be a hostname or IP address. If it's an IPv6 address, it must be enclosed in square brackets. Note this does not parse the toString of a resolved java.net.InetSocketAddress, which is of a host/IP:port form.

      Throws:
        `IllegalArgumentException` - if the port is missing, the string is garbage, or the NetworkHostAndPort constructor rejected the parsed parts.
      See Also:
        `class NetworkHostAndPort`, java.net.InetSocketAddress