@Override
	public void waitForConnection() throws NodeClosedException, InterruptedException {
		synchronized (monitor) {
			while (currentState.equals(State.OPENING) && !Thread.currentThread().isInterrupted())
				monitor.wait();

			if (currentState.equals(State.CONNECTED))
				throw new NodeClosedException();
		}
	}