Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

AnyEvent::Handle::UDP bind

by Darius (Initiate)
on Feb 11, 2014 at 13:53 UTC ( #1074420=perlquestion: print w/ replies, xml ) Need Help??
Darius has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'm developing a perl script to simulate several clients versus a specific Radius server. I have this error when I try to lunch the script:

AnyEvent::Handle::UDP uncaught error: Could not bind: Invalid argument at /usr/local/lib/perl/5.14.2/AnyEvent/Socket.pm line 762.

If I try to put:
bind => '10.0.2.15', 1813,
inside the anyevent everything works fine but I cannot reuse the same code to simulate for example 100 differents clients. For my script the triple (IP-port-packetid) is a client and I need to change the source port in order to change the clients. How can i remove this error ?
Thanks a lot

#!/usr/bin/perl use strict; use warnings; use AnyEvent; use Net::Radius::Dictionary; use Net::Radius::Packet; use AnyEvent::Handle::UDP; use AnyEvent::Socket (); use Socket; use Thread::Queue; use Data::Dump qw( pp ); my %config = ( hostname_accounting => '10.63.95.6', port_accounting => 1813, ); my $cv = AnyEvent->condvar; my $client_radius = AnyEvent::Handle::UDP->new( #bind => ['10.0.2.15', 1813], connect => [$config{hostname_accounting} => $config{port_accountin +g}], on_recv => sub { }, ); for (my $ports = 1000; $ports <= 2000; $ports++){ ############################## my $dict = new Net::Radius::Dictionary 'dictionary' or die "Couldn't read dictionary: $!"; # Open a new object with right dictionary my $req = new Net::Radius::Packet $dict; $req->set_code('Accounting-Request'); #### injection the specific fields: $req->set_attr('Acct-Status-Type','Start'); ##################### # adding some extra info in radius packet....from a threads queue +... ##################### $req->set_authenticator(''); #print pp ($req) . "\n"; #my $packet = auth_resp($req->pack(), $config{secret}); my $packet = auth_resp($req->pack()); ############################## #$client_radius->push_send($packet, pack_sockaddr_in(53, Socket::i +net_aton('10.63.95.6'))); $client_radius->bind_to(['10.0.2.15',$ports]); $client_radius->push_send($packet); } $cv->wait;

Comment on AnyEvent::Handle::UDP bind
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1074420]
Approved by Corion
Front-paged by Tanktalus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2015-07-03 08:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (50 votes), past polls