public void disconnect() {
		boolean disconnected = false;
		synchronized(CONNECTION_LOCK) {
			if(isConnected) {
				logger.fine("Disconnecting from " + serverAddress + ":" + serverPort);
				disconnectQuietly();
				disconnected = true;
			}
			else if(isAttemptingToConnect) {
				logger.fine("Cancelling connect request to " + serverAddress + ":" + serverPort);
				closeConnection();
			}
		}
		if(disconnected && listener != null)
			listener.onDisconnected(ClientConnection.DISCONNECTED_BY_CLIENT);
	}