private int evaluatePort() throws CoreException { int port= SocketUtil.findFreePort(); if (port == -1) { abort(JUnitMessages.JUnitLaunchConfigurationDelegate_error_no_socket, null, IJavaLaunchConfigurationConstants.ERR_NO_SOCKET_AVAILABLE); } return port; }
/** * Returns a free port number on the specified host within the given range, * or -1 if none found. * * @param host name or IP address of host on which to find a free port * @param searchFrom the port number from which to start searching * @param searchTo the port number at which to stop searching * @return a free port in the specified range, or -1 of none found * @deprecated Use <code>findFreePort()</code> instead. It is possible that this * method can return a port that is already in use since the implementation does * not bind to the given port to ensure that it is free. */ @Deprecated public static int findUnusedLocalPort(String host, int searchFrom, int searchTo) { for (int i= 0; i < 10; i++) { int port= getRandomPort(searchFrom, searchTo); try (Socket s= new Socket(host, port)){ } catch (ConnectException e) { return port; } catch (IOException e) { } } return -1; }
private int evaluatePort() throws CoreException { int port= SocketUtil.findFreePort(); if (port == -1) { abort(JUnitMessages.JUnitLaunchConfigurationDelegate_error_no_socket, null, IJavaLaunchConfigurationConstants.ERR_NO_SOCKET_AVAILABLE); } return port; }
/** * Returns a free port number on the specified host within the given range, * or -1 if none found. * * @param host name or IP address of host on which to find a free port * @param searchFrom the port number from which to start searching * @param searchTo the port number at which to stop searching * @return a free port in the specified range, or -1 of none found * @deprecated Use <code>findFreePort()</code> instead. It is possible that this * method can return a port that is already in use since the implementation does * not bind to the given port to ensure that it is free. */ @Deprecated public static int findUnusedLocalPort(String host, int searchFrom, int searchTo) { for (int i= 0; i < 10; i++) { int port= getRandomPort(searchFrom, searchTo); try (Socket s= new Socket(host, port)){ } catch (ConnectException e) { return port; } catch (IOException e) { } } return -1; }
subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Finding_free_socket____2); int port= SocketUtil.findFreePort(); if (port == -1) { abort(LaunchingMessages.StandardVMDebugger_Could_not_find_a_free_socket_for_the_debugger_1, null, IJavaLaunchConfigurationConstants.ERR_NO_SOCKET_AVAILABLE);
subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Finding_free_socket____2); int port= SocketUtil.findFreePort(); if (port == -1) { abort(LaunchingMessages.StandardVMDebugger_Could_not_find_a_free_socket_for_the_debugger_1, null, IJavaLaunchConfigurationConstants.ERR_NO_SOCKET_AVAILABLE);
int port = SocketUtil.findFreePort(); VMRunnerConfiguration runConfig = launchTypes(configuration, launch, javaProject, port, mode);