private void sendMsg(TsapiRequest req, CSTAPrivate priv) throws IOException {
		synchronized (this.out) {
			IntelByteArrayOutputStream acBlock = new IntelByteArrayOutputStream(
					18);
			IntelByteArrayOutputStream encodeStream = new IntelByteArrayOutputStream();
			IntelByteArrayOutputStream privateData = new IntelByteArrayOutputStream(
					priv != null ? 34 + priv.data.length : 0);

			try {
				log.info("Sent InvokeID " + req.getInvokeID() + " for "
						+ this.debugID);
				if (log.isDebugEnabled()) {
					Collection<String> lines = req.print();
					for (String line : lines)
						log.debug(line);
				}
				try {
					req.encode(encodeStream);
				} catch (Exception e) {
					log.error("encode: " + e);
				}

				if (priv != null) {
					if (log.isDebugEnabled()) {
						for (String str : priv.print()) {
							log.debug(str);
						}
					}
					int length = priv.vendor.length();
					byte[] vendor = priv.vendor.getBytes();
					for (int i = 0; i < 32; i++) {
						privateData.write(i < length ? vendor[i] : 0);
					}
					privateData.writeShort(priv.data.length);
					privateData.write(priv.data, 0, priv.data.length);
				}

				acBlock.writeShort(1);
				acBlock.writeInt(req.getInvokeID());
				acBlock.writeInt(0);
				acBlock.writeShort(req.getPDUClass());
				acBlock.writeShort(req.getPDU());
				acBlock.writeShort(encodeStream.size());
				acBlock.writeShort(privateData.size());

				this.out.writeInt(acBlock.size() + encodeStream.size()
						+ privateData.size());
				acBlock.writeTo(this.out);
				encodeStream.writeTo(this.out);
				privateData.writeTo(this.out);

				this.channel.write(this.out);
				this.out.reset();
			} finally {
				privateData.close();
				encodeStream.close();
				acBlock.close();
			}

		}
	}