I'm not sure what you're trying to do here. Windows already does DHCP for you. But nevertheless:

  1. use strict; use warnings;
  2. When I run this on Strawberry 5.18.1 MSWin32-x64-multi-thread on Windows 7 x64, I get:
    "Can't create socket: IO::Socket::INET: Only one usage of each socket address (protocol/network address/port) is normally permitted."

This makes sense as my local UDP 68 port is in use by svchost.exe for DHCP services already. When I switch to a non-well-known-port (e.g., 6800) it runs but it doesn't send the packet out the interface I expected - which may be your problem when using the alternate NIC. I determined this with a packet capture (Wireshark) capturing on all interfaces with filter 'udp.srcport == 6800'.

Windows has a preferred interface to send traffic out when there are several matches in the host route table. In this case, your destination of 255.255.255.255 could be for *any* network interface / card, so the default one is used, which by priority, may not be the one you "want".


In reply to Re: why i don't receive DHCPDiscover message from server using dongle and why same code give DHCPNac on wifi by VinsWorldcom
in thread why i don't receive DHCPDiscover message from server using dongle and why same code give DHCPNac on wifi by ppp

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.