Page 1 of 1

TIdUDPServer

PostPosted: Tue Oct 04, 2011 7:35 am
by Lena
C++ Builder XE.
Start new project. Put on Form IdUDPServer1. Then double click in Object Inspector on event OnUDPRead.
I got message:
Error in module Unit1: Incorrect method declare in class TForm1
How I can fix it?
Thanks.

Re: TIdUDPServer

PostPosted: Tue Oct 04, 2011 11:33 am
by volvo877
It's known problem with XE... The only thing you can do now - assign the event handler in code instead of assigning it in Object Inspector.

Re: TIdUDPServer

PostPosted: Wed Oct 05, 2011 1:59 am
by Lena
Is it correct?
Code: Select all
void __fastcall UDPServer1UDPRead(TIdUDPListenerThread *AThread, TBytes *AData, TIdSocketHandle *ABinding)
{
 //
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
 IdUDPServer1->OnUDPRead = *(TUDPReadEvent *)&UDPServer1UDPRead;
}


In XE2 also problem with OnUDPRead: http://qc.embarcadero.com/wc/qcmain.asp ... px?d=98590

Re: TIdUDPServer

PostPosted: Wed Oct 05, 2011 2:09 am
by volvo877
Code: Select all
void __fastcall TForm1::UDPServer1UDPRead(TIdUDPListenerThread *AThread, TBytes AData, TIdSocketHandle *ABinding)
{
//
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
   IdUDPServer1->OnUDPRead = UDPServer1UDPRead;
}
?

AData is NOT a pointer...

Re: TIdUDPServer

PostPosted: Wed Oct 05, 2011 4:42 am
by Lena
Thank you!

Re: TIdUDPServer

PostPosted: Wed Oct 05, 2011 5:14 am
by Lena
I try to use this example: http://www.youtube.com/watch?v=hCF1e8Z2 ... efresh_sun
I have problem if I sent russian charset (привет). I receive "??????". How I can fix it?

Re: TIdUDPServer

PostPosted: Wed Oct 05, 2011 6:36 am
by Lena
Solution:
IdUDPClient1->Send(Edit2->Text, TEncoding::UTF8);

Memo1->Lines->Add(BytesToString(AData, TEncoding::UTF8));