static void begin() throws IOException {
		
		final InputStream inputStream = socket.getInputStream();
		final OutputStream outputStream = socket.getOutputStream();
		final DynamicObjectInputStream in = new DynamicObjectInputStream(inputStream);
		final ObjectOutputStream out = new ObjectOutputStream(outputStream);
		
		Thread output = new Thread() {
			@Override
			public void run() {
				 while(true) {
					 readMessage(in);
				}
			}
		};
		output.setDaemon(true);
		output.start();

		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
			
		while(true) {
			messageTime = new Date();
			String messageTimeString = new String(sdf.format(messageTime,new StringBuffer(),new FieldPosition(0)));
			try {
				String message = new String(r.readLine());
				if (message.equals("\\quit")) {
					System.out.println(messageTimeString+" [Client] Connection terminated.");
					return;
				}
				if (message.startsWith("\\nick")) {
					writeMessage(new ChangeNickMessage(message.substring(6)), out);
				} else if (message.startsWith("\\")) {
					System.out.println(messageTimeString+" [Client] Unknown command \""+ message.substring(1)+"\".");
				} else {
					writeMessage(new ChatMessage(message), out);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		
	}