private int readMsgLength(InputStream in) throws IOException {
		int msgLength = 0;
		int multiplier = 1;
		int digit;
		do {
			digit = in.read();
			msgLength += (digit & 0x7f) * multiplier;
			multiplier *= 128;
		} while ((digit & 0x80) > 0);
		return msgLength;
	}