public void start() {
		try {
			Socket socket;
			try {
				socket = new Socket(HOSTNAME, PORT);
			} catch (ConnectException e) {
				System.err.println("Error connecting");
				System.exit(-1);
				return;
			}
			out = new ObjectOutputStream(socket.getOutputStream());
			in = new ObjectInputStream(socket.getInputStream());
			System.out.println("Connected to server " + HOSTNAME + ":" + PORT);
		} catch (IOException ioe) {
			System.err.println("Can not establish connection to " + HOSTNAME + ": " + PORT);
			ioe.printStackTrace();
			System.exit(-1);
		}

		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				mw = new MainWindow(out);
			}
		});

		while (true) {
			Object object = null;
			
			try {
				object = in.readObject();
			} catch (IOException  e) {
				System.out.println("IOException");
			}
			catch (ClassNotFoundException e) {
				System.out.println("ClassNotFoundException");
			}
			
			if (object == null)
				break;
			if (!(object instanceof Protocol))
				continue;
			Protocol protocol = (Protocol)object;
			handleProtocol(protocol);
		}
	}