Is there an internal size limit of TIdtcpserver buffer? How come whatever method I use, It reaches a limit of 65535?
I have encountered this buffer issue of TidTCPSever these days. My code is very basic: preset the size of buffer array, extract server byte from InputBuffer, and copy buffer array to workspace. Here is the code
TByteDynArray buffer; // decliared in private
void __fastcall TmodWifiCom::IdServerExecute(TIdContext *AContext)
{
long readLength;
int c, s;
byte b;
DataH->FDataReceivedBytes=0;
AContext->Connection->IOHandler->CheckForDataOnSource(10);
while (!AContext->Connection->IOHandler->InputBufferIsEmpty()) {
// get hint of size of buffer
s = AContext->Connection->IOHandler->InputBuffer->Size;
buffer.set_length(s);
AContext->Connection->IOHandler->InputBuffer->ExtractToBytes(buffer,-1,false);
readLength = buffer.Length;
for (long i = 0; i < readLength; i++) {
b = buffer[i];
DataH->FDataBuffer[DataH->FDataReceivedBytes++]=b; // copy buffer bytes to workspace
}
// process workspace
}
}
The code appears to work fine, readLength and s are equal. FDataBuffer appears to recieve every bytes. However, as TidTCPSever reaches a limit deque fails.
// private of head file in other class
frameQue_Type frameQue0;
deque<frameQue_Type> frameQue;
// cpp file in other class
frameQue.push_back(frameQue0);
...
frameQue0 = DataH->frameQue.pop_front(); // [ERROR STOPS HERE]
The error message was: access volation #0048D893
I don't understand:
- TidTCPSever and deque are in different classes
- struct values in deque seem fine
- Error occured as soon as buffer size reaches 65535 bytes
Am I using the buffer right?