|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.wst.server.core.util.SocketUtil
A utility class for socket-related function. It's main purposes are to find unused ports, check whether a port is in use, and check whether a given address is a local(host) address.
Method Summary | |
---|---|
static int |
findUnusedPort(int low,
int high)
Finds an unused port between the given from and to values. |
static boolean |
isLocalhost(java.lang.String host)
Checks if the given host (name or IP address) is pointing to the local machine. |
static boolean |
isPortInUse(int port)
Checks to see if the given port number is being used. |
static boolean |
isPortInUse(int port,
int count)
Checks to see if the given port number is being used. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static int findUnusedPort(int low, int high)
low
- lowest possible port numberhigh
- highest possible port number
-1
if no used ports could be foundpublic static boolean isPortInUse(int port, int count)
true
if the given port is in use, and false
otherwise. Retries every 500ms for "count" tries.
port
- the port number to checkcount
- the number of times to retry
true
if the port is in use, and
false
otherwisepublic static boolean isPortInUse(int port)
true
if the given port is in use, and false
otherwise.
port
- the port number to check
true
if the port is in use, and
false
otherwisepublic static boolean isLocalhost(java.lang.String host)
This method will not attempt to make an external network connection, so it returns quickly and is safe to use in UI interfaces.
host
- a hostname or IP address
true
if the given host is localhost, and
false
otherwise
|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |