IO::Socket::INET: Address already in use

Discussion in 'Perl Misc' started by hagen, Feb 20, 2004.

  1. hagen

    hagen Guest

    I try to write a dhcp-client to get user defined dhcp option.I'm
    stranding already with this reduced script:


    use IO::Socket::INET;

    $sock = IO::Socket::INET->new(ReuseAddr => '1',
    LocalPort => '68',
    Proto => 'udp') or die "can't bind:
    [email protected]\n";

    this dies with: "IO::Socket::INET: Address already in use"

    some ideas?

    thanx, hagen
    hagen, Feb 20, 2004
    1. Advertisements

  2. hagen

    chatiman Guest

    If i remember when you close a socket, it stays open for a certain amount of
    time (a few minutes or seconds).
    So you have to wait a bit before you open the socket for a second time.
    chatiman, Feb 20, 2004
    1. Advertisements

  3. On Fri, 20 Feb 2004 16:42:03 +0100, chatiman wrote: [Don't top post - it's
    [re-ordered to proper format]

    Are you using BOOTP on the client? If so, disable it or use another
    port - because port 68 may be in use on your box :)
    This isn't a true statement. First, the OP is using UDP. The statement
    you made *may* be true if the OP was trying to use TCP instead. UDP is
    connectionless - so, once the packets leaves the client, it's done. Plus,
    the port being used is a reserved port (below 1024). Depending upon
    what's running on the client box, the port may actually be in use. The
    same applies to,say, port 123 (which is the port typically used for NTP).
    If the client was using NTP to sync time, then the above script would fail
    - because the client was, in fact, using port 123 (meaning, it's running
    ntpd or xntpd).



    Copyright notice: all code written by the author in this post is
    released under the GPL.
    for more information.

    a fortune quote ...
    !07/11 PDP a ni deppart m'I !pleH
    James Willmore, Feb 20, 2004
  4. hagen

    hagen Guest

    Thank you Jim. There was a running DHCP client.
    If this is shutted down (ifdown-dhcp eth0), I don't fall in this trap...

    hagen, Feb 21, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.