Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^14: UDP connection

by BrowserUk (Patriarch)
on May 08, 2012 at 12:09 UTC ( [id://969431]=note: print w/replies, xml ) Need Help??


in reply to Re^13: UDP connection
in thread UDP connection

Try this:

#! perl -slw use strict; use threads; use IO::Socket; $|++; use constant SERVER => '127.0.0.1'; use constant MAXIN => 65536; my $noBlock = 1; my @svrs = map{ IO::Socket::INET->new( Proto => 'udp', PeerHost => SERVER, PeerPort => $_ ) or die $!; } 8003, 8008, 8019, 8020; for my $svr ( @svrs ) { async { open my $lsn, '<&', fileno( $svr ) or die "$!,/ $^E"; ioctl( $lsn, 0x8004667e, \$noBlock ); while( 1 ) { select'','','',0.1; recv( $lsn, my $in, MAXIN, 0 ); next unless length $in; next if length( $in ) == 1 and ord( $in ) == 25; print "<$in"; } }->detach; } while( sleep 5 ) { $_->send( chr( 1 ) ) for @svrs; }

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (1)
As of 2024-04-25 00:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found