티스토리 뷰

- 컴파일러: C++Builder 2010 / Indy 10.5.5


//---------------------------------------------------------------------------
#include "VCL.H"
#pragma hdrstop 
#include "_fmMain.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "IdBaseComponent"
#pragma link "IdComponent"
#pragma link "IdUDPBase"
#pragma link "IdUDPClient"
#pragma link "IdUDPServer"
#pragma link "Spin"
#pragma resource "*.dfm"
TfmMain *fmMain;
//---------------------------------------------------------------------------
__fastcall TfmMain::TfmMain(TComponent* Owner)
 : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TfmMain::Button1Click(TObject *Sender)
{
 IdUDPClient1->Host = edtHost->Text;
 IdUDPClient1->Port = spnPort->Value;
 IdUDPClient1->Send(edtSend->Text);
}
//---------------------------------------------------------------------------
void __fastcall TfmMain::IdUDPServer1UDPRead(TIdUDPListenerThread *AThread, TBytes AData,
          TIdSocketHandle *ABinding)
{
 memRead->Lines->Add(BytesToString(AData));
}
//---------------------------------------------------------------------------
void __fastcall TfmMain::Button2Click(TObject *Sender)
{
 IdUDPServer1->DefaultPort = spnServerPort->Value;
 IdUDPServer1->Active = true;
 Button2->Enabled = false;
}
//---------------------------------------------------------------------------