|
현재 폼에다가 TUdpSocket 2개 올려 놓고 송수신 테스트를 해보려 하는데...
OnReceive 이벤트가 계속 안떨어져서 미치겠습니다. 데체 몇시간째 삽질인지...
개발은 윈7, 볼랜드 스튜디오 2006에서 개발하고 있습니다.
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
UdpSocket1->LocalHost = "127.0.0.1";
UdpSocket1->LocalPort = "9999";
UdpSocket1->RemoteHost = "127.0.0.1";
UdpSocket1->RemotePort = "8888";
UdpSocket2->LocalHost = "127.0.0.1";
UdpSocket2->LocalPort = "8888";
UdpSocket2->RemoteHost = "127.0.0.1";
UdpSocket2->RemotePort = "9999";
UdpSocket1->Open();
UdpSocket2->Open();
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
UdpSocket1->SendBuf("ABCDEFG", strlen("ABCDEFG"), 0);
}
void __fastcall TForm1::Button2Click(TObject *Sender)
{ // 스트림으로 보내니까 send 이벤트도 안떨어집니다.
TMemoryStream *stream = new TMemoryStream;
stream->Write(Memo1->Text.c_str(), strlen(Memo1->Text.c_str()));
UdpSocket2->SendStream(stream);
delete stream;
}
void __fastcall TForm1::UdpSocket1Receive(TObject *Sender, PChar Buf, int &DataLen)
{
Memo1->Lines->Add("Receive1");
}
void __fastcall TForm1::UdpSocket2Receive(TObject *Sender, PChar Buf, int &DataLen)
{
Memo1->Lines->Add("Receive2");
}
두 컴포넌트 모두 OnReceive 이벤트에서 소켓에 관여된 데이터는 참조하지 않고 저렇게 그냥 메모만 찍어봤습니다.
TUdpSocket의 이벤트를 모두 테스트 해봤는데 OnReceive만 안나오네요.. 구글링도 해보고 정말 열심히 찾아봤는데 진짜 모르겠어서 이렇게 질문 드립니다.
TUdpSocket에서 OnReceive 이벤트 어떻게 해야 나올까요??
|