public int sizeOfWsFrameLength(byte type, int length) throws IOException {
		// one bite for the type
		int size = 1;
		// Encode length.
		int b1 = length >>> 28 & 0x7F;
		int b2 = length >>> 14 & 0x7F;
		int b3 = length >>> 7 & 0x7F;
		if (b1 == 0) {
			if (b2 == 0) {
				if (b3 == 0) {
					size += 1;
				} else {
					size += 2;
				}
			} else {
				size += 3;
			}
		} else {
			size += 4;
		}
		return size;
	}