#IdTCPServer
#IdTCPServer
void __fastcall TForm1::IdTCPServer1Connect(TIdContext *AContext)
{
AnsiString IP = "Connect : " + AContext->Binding->PeerIP;
ListBox1->Items->Add(IP);
}
// 현재 접속된 Client의 IP주소를 읽어서 ListBox에 Display한다.
//---------------------------------------------------------------------------
void __fastcall TForm1::IdTCPServer1Disconnect(TIdContext *AContext)
{
AnsiString IP = "Disconnect : " + AContext->Binding->PeerIP;
ListBox1->Items->Add(IP);
}
//Disconnect할 Client의 IP주소를 읽어서 ListBox에 Display한다.
void __fastcall TForm1::IdTCPServer1Execute(TIdContext *AContext)
{
AnsiString Message;
try{
Message = AContext->Connection->IOHandler->ReadLn("", enUTF8);
// Client로부터의 입력을 대기
}catch(...){
Close();
}
ListBox1->Items->Add(Message);
AContext->Connection->Socket->WriteLn(Message, enUTF8);
AnsiString Name = GetData(Message, "Name");
AnsiString 메세지내용 = GetData(Message, "Msg"); // 한글변수 사용가능.
AnsiString temp = Name +": " + 메세지내용;
ListBox1->Items->Add(temp);
}