private RdpPacket_Localised receiveMessage(int[] type) throws IOException,
			RdesktopException, OrderException, CryptoException {
		logger.debug("ISO.receiveMessage");
		RdpPacket_Localised s = null;
		int length, version;

		next_packet: while (true) {
			logger.debug("next_packet");
			s = tcp_recv(null, 4);
			if (s == null)
				return null;

			version = s.get8();

			if (version == 3) {
				s.incrementPosition(1); // pad
				length = s.getBigEndian16();
			} else {
				length = s.get8();
				if ((length & 0x80) != 0) {
					length &= ~0x80;
					length = (length << 8) + s.get8();
				}
			}

			s = tcp_recv(s, length - 4);
			if (s == null)
				return null;
			if ((version & 3) == 0) {
				logger.debug("Processing rdp5 packet");
				Common.rdp.rdp5_process(s, (version & 0x80) != 0);
				continue next_packet;
			} else
				break;
		}

		s.get8();
		type[0] = s.get8();

		if (type[0] == DATA_TRANSFER) {
			logger.debug("Data Transfer Packet");
			s.incrementPosition(1); // eot
			return s;
		}

		s.incrementPosition(5); // dst_ref, src_ref, class
		return s;
	}