@Override
	public void run() {
		//try {
			//socket.connect(socket.getRemoteSocketAddress());
		//} catch (IOException e1) {
			// TODO Auto-generated catch block
		//	e1.printStackTrace();
		//}
		///a~
		while(true){
			try {
				ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
				MessageObject mo = (MessageObject) ois.readObject();
				System.out.println("--- Message Received ---\n" + mo.toString());
				System.out.println("From: " + mo.getSrceName() + " (" +
						"" + socket.getRemoteSocketAddress() + ") To: " + socket.getLocalAddress());
				if(!(mo instanceof EndMessage)){
					messageEvent(mo);
				}else{
					//if EndMessage received, close the socket and tell listener about it.
					socket.close();
					messageEvent(mo);
					break;
				}
			} catch (SocketException e){
				//for the case that connection is broken
				break;
			} catch (ClassNotFoundException | IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				try {
					socket = new Socket(servAddr, 53346);
				} catch (IOException e1) {
					// TODO Auto-generated catch block
					break;
				}
			}
		}
		try {
			socket.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}