13,825
社区成员
发帖
与我相关
我的任务
分享
void __fastcall TForm1::IdTCPServer1Execute(TIdContext *AContext)
{
a++;
unsigned char c[6];
unsigned char c1[16];
for (int i = 0; i < 6; i++)
{
断点处: c[i] = AContext->Connection->IOHandler->ReadByte();
}
String str = (char*)c;
for(int j = 0; j <16; j++)
{
c1[j] = AContext->Connection->IOHandler->ReadByte();
}
String final = (char*)c1;
if(str == "XXXCID")
{
ListBox2->Items->Add(str + final);
TByteDynArray buf;
unsigned char msg[] = "XXXCID\x3e\x02\x01\x01\x01\x02\x01\x03\x02\x04\x01\x05\x02\x06\x01\x07\x01\x08\x01";
buf = RawToBytes(static_cast<void*>(msg),sizeof(msg)-1);
AContext->Connection->IOHandler->Write(buf);
}
}
unsigned char nc[6] = {'a','b','c','d','e','f'};
String s = (char *)nc;
void __fastcall TForm1::IdTCPServer1Execute(TIdContext *AContext)
{
AContext->Connection->IOHandler->CheckForDataOnSource(10);
if(AContext->Connection->IOHandler->InputBufferIsEmpty())
{
return;
}
AContext->Connection->IOHandler->ReadTimeout = 10;
a++;
unsigned char c[7] = {NULL};
unsigned char c1[17] = {NULL};
for (int i = 0; i < 6; i++)
{
c[i] = AContext->Connection->IOHandler->ReadByte();
}
String str = (char*)c;
if(str == "XXXCID")
{
for(int j = 0; j <16; j++)
{
c1[j] = AContext->Connection->IOHandler->ReadByte();
}
String final = (char*)c1;
ListBox2->Items->Add(str + final);
TByteDynArray buf;
unsigned char msg[] = "XXXCID\x3e\x02\x01\x01\x01\x02\x02\x03\x01\x04\x02\x05\x01\x06\x02\x07\x01\x08\x02";
buf = RawToBytes(static_cast<void*>(msg),sizeof(msg)-1);
AContext->Connection->IOHandler->Write(buf);
aa++;
}
}
void __fastcall TForm1::IdTCPServer1Execute(TIdContext *AContext)
{
AContext->Connection->IOHandler->CheckForDataOnSource(10);
// 如果输入缓冲为空就返回
if (AContext->Connection->IOHandler->InputBufferIsEmpty()) return;
a++;
...
}