IdTCPServer 组件使用,编译时报错
网上的,“用Indy组件开发Socket应用程序”
void __fastcall TForm1::IdTCPServer1Execute(TIdPeerThread *AThread)
{
String sCommand;
String FLogEntry;
//with AThread.Connection do
sCommand=AThread->Connection-> ReadLn();
FLogEntry = sCommand + " 来自于主机 "+ AThread->Connection->Socket->Binding->PeerIP;
AThread->Synchronize(ListBox1->Items->Add("来自主机 "+ AThread->Connection->Socket->Binding->PeerIP));
//if (AnsiStartsText("DATA ", sCommand) )
if (SameText(sCommand, "DATA") )
{
Edit2->Text = RightStr(sCommand, Length(sCommand)-5);
AThread->Connection->WriteLn("200: 数据接收成功!");
AThread->Synchronize(Edit2->Text);
}
else if (SameText(sCommand, "QUIT") )
{
FLogEntry = "断开同主机 "+ AThread->Connection->Binding->PeerIP+ " 的连接!";
AThread->Synchronize(ListBox1->Items->Add("断开同主机 "+ AThread->Connection->Socket->Binding->PeerIP+ " 的连接!"));
AThread->Connection=Disconnect;
}
else {
AThread->Connection->WriteLn("500: 无法识别的命令!");
FLogEntry = "无法识别命令:" + sCommand;
AThread->Synchronize(ListBox1->Items->Add("来自主机 "+ AThread->Connection->Socket->Binding->PeerIP));
}
}
//---------------------------------------------------------------------------
编译时系统报错 :
[C++ Error] Unit1.cpp(53): E2316 'Socket' is not a member of 'TIdTCPServerConnection'
[C++ Error] Unit1.cpp(58): E2268 Call to undefined function 'Length'
[C++ Error] Unit1.cpp(66): E2451 Undefined symbol 'Disconnect'
新手,请指导。。。