@Override
	public void run() {
		StringBuffer buf = new StringBuffer();
		Socket s = null;
		try {
			s = new Socket(InetAddress.getLocalHost(), this.port);
		} catch (UnknownHostException e) {
			log.severe(e.toString());
		} catch (IOException e) {
			log.severe(e.toString());
		}
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			if (initCom(s, key)) {
				Message.encryptAndSend(buf.toString(), s, this.pass);
				while (this.isRunning) {
					System.out.print("Send to server: ");
					buf.append(br.readLine());
					Message.encryptAndSend(buf.toString(), s, this.pass);
					buf.setLength(0);
				}
			} else {
				isRunning = false;
			}
		} catch (Exception e) {
			try {
				shutdown(br, s);
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		}
	}