1,593
社区成员
发帖
与我相关
我的任务
分享
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if(Edit2->Text=="")
{
ShowMessage("无内容");
return;
}
if(IdTCPServer1->Contexts->Count()<1)
{
ShowMessage("客户端未连接");
return;
}
try
{
TIdContextList *AList=IdTCPServer1->Contexts->LockList();
TIdContext *AContext=(TIdContext *)AList->Items[0];
AContext->Connection->IOHandler->WriteLn(Edit2->Text,IndyTextEncoding(TEncoding::Default));
Edit2->Text="";
}
__finally
{
IdTCPServer1->Contexts->UnlockList();
}
}
//---------------------------------------------------------------------------