public void connect(String username, InetAddress server, int flags,
			String domain, String password, String command, String directory)
			throws ConnectionException {
		try {
			SecureLayer.connect(server);
			this.connected = true;
			this.sendLogonInfo(flags, domain, username, password, command,
					directory);
		}
		// Handle an unresolvable hostname
		catch (UnknownHostException e) {
			throw new ConnectionException("Could not resolve host name: "
					+ server);
		}
		// Handle a refused connection
		catch (ConnectException e) {
			throw new ConnectionException(
					"Connection refused when trying to connect to " + server
							+ " on port " + Options.port);
		}
		// Handle a timeout on connecting
		catch (NoRouteToHostException e) {
			throw new ConnectionException(
					"Connection timed out when attempting to connect to "
							+ server);
		} catch (IOException e) {
			throw new ConnectionException("Connection Failed");
		} catch (RdesktopException e) {
			e.printStackTrace();
			throw new ConnectionException(e.getMessage());
		} catch (OrderException e) {
			throw new ConnectionException(e.getMessage());
		} catch (CryptoException e) {
			throw new ConnectionException(e.getMessage());
		}

	}