Class InetSocketAddressUtil


  • public final class InetSocketAddressUtil
    extends Object
    Created as a util for test tools.
    • Method Detail

      • toHostAndPort

        public static com.google.common.net.HostAndPort toHostAndPort​(InetSocketAddress address)
      • getRandomLoopbackInetSocketAddress

        public static InetSocketAddress getRandomLoopbackInetSocketAddress​(int port)
      • getRandomLoopbackInetSocketAddress

        public static InetSocketAddress getRandomLoopbackInetSocketAddress()
      • getRandomPort

        public static int getRandomPort()
        Generate a random high range port number.
        Returns:
        A port number range from 20000 to 60000
      • getRandomLoopbackIpAddress

        public static String getRandomLoopbackIpAddress()
        Generate a random loopback ip address. IP address range: 127.50.50.50 ~ 127.250.250.250 We did not utilize the whole 127./8 range to avoid using common addresses like 127.0.0.1
        Returns:
        Generated random loopback IP address