void SendStreamData(RecordType type, byte [] data,
int length)
{
// Records are only able to hold 65535 bytes of data. If
// larger data is to be sent, it must be broken into
// smaller components.
if (length > data.Length)
{
length = data.Length;
}
const int maxSize = 0x7fff;
if (length < maxSize)
{
connection.SendRecord(type, RequestID, data, 0,
length);
}
else
{
int index = 0;
while (index < length)
{
int chunkLength = (maxSize <
length - index) ? maxSize :
(length - index);
connection.SendRecord(type, RequestID,
data, index, chunkLength);
index += chunkLength;
}
}
}