header |= (sizeType & 0x03) << 0;
int index = indexOf(frame);
int length = frames.length;
MemoryStream ms = new MemoryStream();
ms.write(header);
if (sizeType == 1) {
ms.write(((index & 0x0f) << 4) | ((length & 0x0f) << 0));
} else if (sizeType == 2) {
ms.write(index);
ms.write(length);
} else {
ms.writeShort(index);
ms.writeShort(length);
}
ms.write(frame.getData());
byte[] data = ms.toByteArray();
DatagramPacket packet = new DatagramPacket(data, data.length);
getSocket().send(packet);
frame.incrementSendCount();
return true;
}