Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Mar : Re: UDPServer Assign Event Handler Not Working
| Subject: | Re: UDPServer Assign Event Handler Not Working |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Tue, 11 Mar 2008 21:09:00 |
"Adrian" <heyadrian99@hotmail.com> wrote in message
news:47d73fb2$1@newsgroups.borland.com...
> I am trying to make a DLL that simply broadcasts a message out
> using UDP and through a custom port. I assign a custom function
> to the event OnUDPRead but it never gets triggered, and I am not
> sure why not...
Because you are listening for data on the wrong Port.
> UDPServer.OnUDPRead := DummyClass.UDPServerRead;
You should be setting that before setting the Active property, not
afterwards. Otherwise, you risk missing data that could arrive right away.
> UDPServer.DefaultPort := 33;
You must set that value before setting the Active property, not afterwards.
Setting it has no effect after the server is already activated. Since you
are not setting it beforehand, the Port used is still 0 when the server is
activated, and so it ends up listening on a random port instead of the one
you wanted.
Gambit