public static boolean portAvailable(int port) {
		ServerSocket serverSocket = null;
		try {
			serverSocket = new ServerSocket(port);
			serverSocket.setReuseAddress(true);
		} catch(IOException e) {
			// do nothing
			return false;
		} finally {
			if (null != serverSocket && !serverSocket.isClosed()) {
				try {
					serverSocket.close();
				} catch(IOException e) {
					// do nothing
				}
			}
		}

		Socket socket = null;
		try {
			socket = new Socket("localhost", port);
		} catch (UnknownHostException e) {
			// do nothing
		} catch(IOException e) {
			return true;
		} finally {
			if (null != socket && !socket.isClosed()) {
				try {
					socket.close();
				} catch (IOException e) {
					// do nothing
				}
			}
		}

		return false;
	}