synchronized public void writeFence(int flags, int len, byte[] data)
  {
    if (!cp.supportsFence)
      throw new ErrorException("Server does not support fences");
    if (len > 64)
      throw new ErrorException("Fence payload too large");
    if ((flags & ~fenceTypes.fenceFlagsSupported) != 0)
      throw new ErrorException("Unknown fence flags");

    startMsg(MsgTypes.msgTypeClientFence);
    os.pad(3);

    os.writeU32(flags);

    os.writeU8(len);
    os.writeBytes(data, 0, len);

    endMsg();
  }