public void run() {
		while(running) {
			try {
				// Make sure we are still connected
				if(socket.isClosed()) {
					System.out.println("Socket was closed!");
					this.cleanup();
					running = false;
					return;
				}
				
				// Read header
				int size = -1;
				
				try {
					size = in.readUnsignedShort();
				} catch(EOFException e) {
					System.out.println("READ ERROR");
					this.cleanup();
					running = false;
					return;
				} catch(IOException e) {
					System.out.println("Connection was closed!");
					this.cleanup();
					running = false;
					return;
				}
				
				// Check if we got a message
				if(size == -1) {
					Thread.sleep(1);
				} else {
					// Make sure there is some data
					if(size >= 1) {
						// Prepare the message
						Buffer buff = new Buffer(size);
						in.read(buff.getBuffer(), 0, size);
						
						// Process the message
						processMessage(buff);
					}
				}
			} catch (IOException e) {
				e.printStackTrace();
				running = false;
				return;
			} catch (InterruptedException e) {
				e.printStackTrace();
				running = false;
				return;
			}
		}
	}