private void startListenerThread() {

		
		readThread = new Thread() {
			@Override
			public void run() {
				while (!GameState.getInstance().isGameOver()) {
					try {
						Thread.sleep(sleepTime);
					} catch (InterruptedException e) {
						
						e.printStackTrace();
					}
					int offset = 0;

					byte[] header = new byte[messageHeader];
					int remaining = header.length;
					try {
						synchronized (delegate) {
							if (!delegate.shouldRead()) {
								continue;
							}
						}

						while (remaining > 0) {
							remaining -= in.read(header, offset, header.length - offset);

							offset = header.length - remaining;
						}

						String head = new String(header);
						if(head.length()<6)
							continue;
						
						double len ;
						try {
							len =  Double.parseDouble((head.substring(1, 6)));
						} catch (Exception e) {
							// TODO: handle exception
							continue;
						}
						byte[] data = new byte[(int) len];
						offset = 0;
						
						remaining = data.length;

						while(in.available()< len){
						
						}
						while (remaining > 0) {
							remaining -= in.read(data, offset, data.length - offset);
							offset = header.length - remaining;
						}
					

						synchronized (delegate) {
							delegate.readData(data);
						}

					} catch (IOException e) {
						// TODO Auto-generated catch block
						
							delegate.connectionFailed(e.getLocalizedMessage());
						
						
						return;
					}
				}
			}
		};
		readThread.start();

	}