public void run() {
		String str;
		boolean more = true;
		try {
			while (more) {
				// wait for next line from server
				str = sockIn.readLine();
				if (str != null) {
					// parse server message
					parse(str);
				} else
					more = false;
			}
			close();
		} catch (IOException ioe) {
			// if the connection has been closed, handle it properly.
			if (ioe.getMessage().equals("Connection reset")) {
				// print message to console
				System.out.println("Client " + name + " at " + IP
						+ " disconnected.");

				if (operator instanceof ServerOperator) {
					// create a logout event for logging
					Event logout = new Event(operator);
					logout.setEventLogout();
					((ServerOperator) operator).addHistory(logout);
				} else {
					// close the socket cleanly, if possible.
					//java.lang.ClassCastException: server.ServerMessages cannot be cast to client.ClientMessages
					//at shared.Messages.run(Messages.java:137)
					child.close();
				}
				// if some other exception, just dump the stack
			} else {
				ioe.printStackTrace();
				System.out.println("Exception: " + ioe);
			}
		}
		// close the socket cleanly, if possible.
		if (child instanceof ClientMessages) {
			((ClientMessages) child).close();
		}
	}