TIdtcpserver缓冲区是否有内部大小限制?我怎么用我用的方法,达到了65535的限制?
这些天我遇到过TidTCPSever的缓冲问题。我的代码非常基本:预设缓冲区数组的大小,从InputBuffer中提取服务器字节,以及将缓冲区数组复制到工作区。这是代码
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
}
}
代码似乎工作正常,readLength和s相等。 FDataBuffer似乎收到了每个字节。但是,当TidTCPSever达到极限时,deque失败。
// 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]
错误消息为:access volation#0048D893
我不明白:
我正在使用缓冲区吗?