public static int getFreePort() {
		ServerSocket socket = null;
		try {
			socket = new ServerSocket(0);
			return socket.getLocalPort();
		} catch (IOException e) {
			noOp();
		} finally {
			IOUtils.closeQuietly(socket);
		}
		return -1;
	}
Check if the given port is available.

@param inetAddress address to be bound
@param port        port to be checked
@return true if available
ngrinder-core/src/main/java/net/grinder/util/NetworkUtils.java