Package org.eclipse.jdt.launching
Class SocketUtil
java.lang.Object
org.eclipse.jdt.launching.SocketUtil
Utility class to find a port to debug on.
- Restriction:
- This class is not intended to be subclassed by clients.
- Restriction:
- This class is not intended to be instantiated by clients.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
Returns a free port number on localhost, or -1 if unable to find a free port.static int
findUnusedLocalPort
(String host, int searchFrom, int searchTo) Deprecated.
-
Constructor Details
-
SocketUtil
public SocketUtil()
-
-
Method Details
-
findUnusedLocalPort
Deprecated.UsefindFreePort()
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.Returns a free port number on the specified host within the given range, or -1 if none found.- Parameters:
host
- name or IP address of host on which to find a free portsearchFrom
- the port number from which to start searchingsearchTo
- the port number at which to stop searching- Returns:
- a free port in the specified range, or -1 of none found
-
findFreePort
public static int findFreePort()Returns a free port number on localhost, or -1 if unable to find a free port.- Returns:
- a free port number on localhost, or -1 if unable to find a free port
- Since:
- 3.0
-
findFreePort()
instead.