Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Socket programming

by chubako (Acolyte)
on Aug 08, 2011 at 05:10 UTC ( #919142=note: print w/ replies, xml ) Need Help??


in reply to Socket programming

Not sure that it works right, but it works. :)

use strict; use warnings; use Socket; use AnyEvent; my $udp_server my $udp_socket; sub start_udp_server { my $port = shift || 9000; my $proto = getprotobyname('udp'); my $paddr = Socket::sockaddr_in($port, Socket::INADDR_ANY); socket($udp_socket, Socket::PF_INET, Socket::SOCK_DGRAM, $proto); bind($udp_socket, $paddr); $udp_server = AE::io $udp_socket, 0, sub { my $buff; my $addr = recv($udp_socket, $buff, 256, 0); print $buff; } } start_udp_server(); my $ae_timer = AE::timer 10, 10, sub { print "timer tick\n"; } AE::cv->recv;
You can check it with nc/netcat/ncat:
ncat -u localhost 9000


Comment on Re: Socket programming
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://919142]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2014-07-26 03:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls