TIdUDPServer

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

TIdUDPServer

Postby Lena » Tue Oct 04, 2011 7:35 am

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.
Lena
BCBJ Master
BCBJ Master
 
Posts: 429
Joined: Sun Feb 06, 2011 1:28 pm

Re: TIdUDPServer

Postby volvo877 » Tue Oct 04, 2011 11:33 am

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.
volvo877
 
Posts: 2
Joined: Tue Oct 04, 2011 11:29 am

Re: TIdUDPServer

Postby Lena » Wed Oct 05, 2011 1:59 am

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
Lena
BCBJ Master
BCBJ Master
 
Posts: 429
Joined: Sun Feb 06, 2011 1:28 pm

Re: TIdUDPServer

Postby volvo877 » Wed Oct 05, 2011 2:09 am

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...
volvo877
 
Posts: 2
Joined: Tue Oct 04, 2011 11:29 am

Re: TIdUDPServer

Postby Lena » Wed Oct 05, 2011 4:42 am

Thank you!
Lena
BCBJ Master
BCBJ Master
 
Posts: 429
Joined: Sun Feb 06, 2011 1:28 pm

Re: TIdUDPServer

Postby Lena » Wed Oct 05, 2011 5:14 am

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?
Lena
BCBJ Master
BCBJ Master
 
Posts: 429
Joined: Sun Feb 06, 2011 1:28 pm

Re: TIdUDPServer

Postby Lena » Wed Oct 05, 2011 6:36 am

Solution:
IdUDPClient1->Send(Edit2->Text, TEncoding::UTF8);

Memo1->Lines->Add(BytesToString(AData, TEncoding::UTF8));
Lena
BCBJ Master
BCBJ Master
 
Posts: 429
Joined: Sun Feb 06, 2011 1:28 pm


Return to Technical

Who is online

Users browsing this forum: No registered users and 4 guests

cron