Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UDP-component

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'd like to use an UDP component where I can change the localport. In the helpfile I find that you cannot change the localport at runtime, you have to do it at designtime or after creating the component with create. When I trie to create an udp-component with create I always get the message that create is not a method of UDP. I created the component with new, but as soon as my created component received an udp packet,I get an exception. Can anybody help me ?
 
What is an exception you got? Happy programming!))
 
The exception is EAccesViolation. I think there is a problem in how I defined the event in my dynamically created component.
this is how I defined the function :
void NMUDP1DataReceived(TComponent *Sender,
int NumberBytes, AnsiString FromIP);

and this is how I declared it as an event :
NMUDP1->OnDataReceived=(TOnReceive)& NMUDP1DataReceived;
I have the feeling that this is not correct ....
Wim Vanherp
Wim.Vanherp@myself.com
 
Greetinx!

This is an Pascal declaration of OnDataReceivedEvent

TOnReceive = procedure(Sender: TComponent; NumberBytes: Integer; FromIP: string; Port: integer) of object;

so you need to declare event handle like follow:
void __fastcall TForm1::NMUPD1DataReceived(TComponent *Sender, int NumberBytes, AnsiString FrimIP, int Port);
Happy programming!))
 
In builder there is no port -parameter in ther parameter section, so that's not thd problem. I think the problem lies in the syntax of declaring an event in a dynamicaly created component . Wim Vanherp
Wim.Vanherp@myself.com
 
Greetinx!

The port parameter is present in my Builder! So earlier declaration is true.


Happy programming!))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top