private void listen() {
		try {
		// Listen for messages from server
		Object dataFromServer;
			while (true) {
				if (this.isConnected()) {
						if ((dataFromServer = in.readObject()) != null) {
							receive(dataFromServer);
						}
				} else {
					this.close();
				}
			}
		} catch (EOFException|SocketException e) {
			try {
				this.close();
			} catch (IOException ioe) {
				ioe.printStackTrace();
			}
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}