Package org.ghost4j.util
Class NetworkUtil
- java.lang.Object
-
- org.ghost4j.util.NetworkUtil
-
public class NetworkUtil extends java.lang.ObjectNetwork utilities class.
-
-
Constructor Summary
Constructors Constructor Description NetworkUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intfindAvailablePort(java.lang.String hostname, int startPort, int endPort)Finds an available port within a port range on a hoststatic voidwaitUntilPortListening(java.lang.String hostname, int port, int timeout)Waits until a port is listening on a given host.
-
-
-
Method Detail
-
findAvailablePort
public static int findAvailablePort(java.lang.String hostname, int startPort, int endPort)Finds an available port within a port range on a host- Parameters:
hostname- Host namestartPort- Port number starting the rangeendPort- Port number ending the range- Returns:
- An available port number, or 0 if none is available.
-
waitUntilPortListening
public static void waitUntilPortListening(java.lang.String hostname, int port, int timeout) throws java.io.IOExceptionWaits until a port is listening on a given host. An exception is thrown if the timeout is excedeed.- Parameters:
hostname- Host nameport- Port numbertimeout- Timeout in seconds- Throws:
java.io.IOException- If a connection error occurs or if the timeout is exceeded
-
-