Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

UDP server in POE

by jczeus (Monk)
on Oct 31, 2007 at 10:05 UTC ( #648208=perlquestion: print w/replies, xml ) Need Help??
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://648208]
Approved by planetscape
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2018-06-20 12:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (116 votes). Check out past polls.

    Notices?