public boolean connect(String ip, int port) {
		try {
			clientSocket = new Socket(ip, port);
			outToServer = new ObjectOutputStream(clientSocket.getOutputStream());
			inFromServer = new ObjectInputStream(clientSocket.getInputStream());
			while (((String)inFromServer.readObject()).startsWith("1")) {
				gui.requestName();
				outToServer.writeObject(gui.name);
			}
			
		} catch (UnknownHostException e) {
			System.out.println("Unknown host.");
			clientSocket = null;
			outToServer = null;
			inFromServer = null;
			gui.connected = false;
			return false;
		} catch (IOException e) {
			System.out.println("IOException encountered while connecting.");
			clientSocket = null;
			outToServer = null;
			inFromServer = null;
			gui.connected = false;
			return false;
		} catch (ClassNotFoundException e) {
			System.out.println("Object received not a String.");
		}
		gui.connected = true;
		return true;
	}