adwald has asked for the wisdom of the Perl Monks concerning the following question:
I am needing to perform a leasequery to multiple servers. HI have tried the following code but it keeps locking on the second server. I cannot find anything online as an example. Can someone provide some assistance?
!/usr/bin/perl -w use IO::Socket::INET; use Net::DHCP::Packet; use Net::DHCP::Constants; $mac=$ARGV[0]; @dhcp = ("10.16.30.4","10.16.30.5","172.31.45.248","172.31.45.249","17 +2.31.35.248","172.31.35.249"); foreach $server (@dhcp) { print "$server\n"; # create a socket $handle = IO::Socket::INET->new(Proto => 'udp', Broadcast => 1, PeerPort => '67', LocalPort => '67', PeerAddr => $server); # create DHCP Packet $inform = Net::DHCP::Packet->new( op => BOOTREQUEST(), Htype => '1', Hlen => '6', Ciaddr => '0', Chaddr => $mac, Giaddr => $handle->sockhost(), Xid => int(rand(0xFFFFFFFF)), # random xid DHO_DHCP_MESSAGE_TYPE() => DHCPLEASEQUERY ); # send request $handle->send($inform->serialize()) or die "Error sending LeaseQuery +: $!\n"; #receive response $handle->recv($newmsg, 1024) or die; $packet = Net::DHCP::Packet->new($newmsg); $data = $packet->toString(); $handle->close(); } print "$data\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: UDP Client Multiple servers
by BrowserUk (Patriarch) on Oct 11, 2012 at 15:55 UTC | |
by adwald (Initiate) on Oct 11, 2012 at 16:22 UTC | |
by zwon (Abbot) on Oct 12, 2012 at 06:30 UTC | |
by brap (Pilgrim) on Oct 12, 2012 at 13:18 UTC | |
by zwon (Abbot) on Oct 12, 2012 at 14:26 UTC | |
|