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";

In reply to UDP Client Multiple servers by adwald

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.