@Test public void testGetRandomPort(){ int port = IpUtil.ramdomAvailablePort(); System.out.println(port); org.junit.Assert.assertTrue(port > 0 && port <65535); }
public static int ramdomAvailablePort(){ int port = 0; do{ port = (int) ((MAX_USER_PORT_NUMBER-MIN_USER_PORT_NUMBER) * Math.random())+MIN_USER_PORT_NUMBER; }while(!availablePort(port)); return port; }
IpUtil { public static int ramdomAvailablePort(){ int port = 0; do{ port = (int) ((MAX_USER_PORT_NUMBER-MIN_USER_PORT_NUMBER) * Math.random())+MIN_USER_PORT_NUMBER; }while(!availablePort(port)); return port; } }
IpUtil { public static int ramdomAvailablePort(){ int port = 0; do{ port = (int) ((MAX_USER_PORT_NUMBER-MIN_USER_PORT_NUMBER) * Math.random())+MIN_USER_PORT_NUMBER; }while(!availablePort(port)); return port; }  }
IpUtil { public static int ramdomAvailablePort(){ int port = 0; do{ port = (int) ((MAX_USER_PORT_NUMBER-MIN_USER_PORT_NUMBER) * Math.random())+MIN_USER_PORT_NUMBER; }while(!availablePort(port)); return port; }  static String intToIp(int i); static int ipToInt(final String addr); static long ipToLong(final String addr); static String longToIp(long i); static boolean isIp(String in); static Map<String,String> getLocalIps(); static String getLocalIp(); static String getSingleLocalIp(); static int ramdomAvailablePort(); static boolean availablePort(int port); static void main(String[] args); }
IpUtil { public static int ramdomAvailablePort(){ int port = 0; do{ port = (int) ((MAX_USER_PORT_NUMBER-MIN_USER_PORT_NUMBER) * Math.random())+MIN_USER_PORT_NUMBER; }while(!availablePort(port)); return port; }  static String intToIp(int i); static int ipToInt(final String addr); static long ipToLong(final String addr); static String longToIp(long i); static boolean isIp(String in); static Map<String,String> getLocalIps(); static String getLocalIp(); static String getSingleLocalIp(); static int ramdomAvailablePort(); static boolean availablePort(int port); static void main(String[] args);  }