jczeus has asked for the wisdom of the Perl Monks concerning the following question:

I want to set up a server in POE that waits for incoming broadcasted UDP packets. There is no POE::Component::Server::UDP. Why? Is there a different way to implement a UDP server in POE?

I had a look at POE::Wheel::UDP (both documentation and source code). It doesn't seem to be very practical: it forces you to specify LocalAddr, which would be a mistake here.

Any suggestions? Of course I would volunteer to write POE::Component::Server::UDP if there's a need for it.

Replies are listed 'Best First'.
Re: UDP server in POE
by Somni (Friar) on Oct 31, 2007 at 10:35 UTC
    The UDP entry in the POE cookbook gives a run-down of setting up a UDP client and server. The page mentions why there's no UDP server component: no one has felt the need enough to write one.

    As for your broadcast question, it's been a while since I messed with UDP sockets, but can't you specify a local address of INADDR_ANY and achieve the effect you want? To get through POE::Wheel::UDP's LocalAddr argument handling you'd have to specify inet_ntoa(INADDR_ANY).

    You might also want to check out POE::Wheel::Multicast, a subclass of POE::Wheel::UDP.

      Thanks for the help!

      Edit: having seen the example in the cookbook, I understand why there is no such thing as POE::Component::Server::UDP. I'll have to see if using POE::Wheel::UDP gives me more flexibility or not, as my app will have to be switchable between TCP (which it does already) and UDP.

Re: UDP server in POE
by Anonymous Monk on Oct 31, 2007 at 10:34 UTC