public class SocketUtil extends Object
Clients are not intended to subclass or instantiate this class.
| Constructor and Description |
|---|
SocketUtil() |
| Modifier and Type | Method and Description |
|---|---|
static int |
findFreePort()
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.
Use
findFreePort() 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. |
public static int findUnusedLocalPort(String host, int searchFrom, int searchTo)
findFreePort() 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.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 searchingpublic static int findFreePort()
Copyright (c) IBM Corp. and others 2000, 2006. All Rights Reserved.