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

		next_packet: while (true) {
			// logger.debug("next_packet");
			GWT.log("tcp receive called");
			s = tcp_recv(null, 4, option);
			GWT.log("tcp receive end");
			if (s == null)
				return null;
			GWT.log("s is not null");
			version = s.get8();

			if (version == 3) {
				GWT.log("version is 3");
				s.incrementPosition(1); // pad
				length = s.getBigEndian16();
			} else {
				GWT.log("version is not 3");
				length = s.get8();
				GWT.log("length:" + Integer.toHexString(length));
				if ((length & 0x80) != 0) {
					length &= ~0x80;
					GWT.log("length:" + Integer.toHexString(length));
					length = (length << 8) + s.get8();
					GWT.log("length:" + Integer.toHexString(length));
				}
			}
			GWT.log("out of version thing, length:" + length);
			s = tcp_recv(s, length - 4, option);
			if (s == null)
				return null;
			if ((version & 3) == 0) {
				// logger.info("Processing rdp5 packet");
				rdpLayer.rdp5_process(s, (version & 0x80) != 0, option);
				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;
	}