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:

    #!/usr/bin/perl

    use IO::Socket::INET;

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

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

    some ideas?

    thanx, hagen
    hagen, Feb 20, 2004
    #1
    1. Advertising

  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.

    "hagen" <> a écrit dans le message de news:
    ...
    > I try to write a dhcp-client to get user defined dhcp option.I'm
    > stranding already with this reduced script:
    >
    > #!/usr/bin/perl
    >
    > use IO::Socket::INET;
    >
    > $sock = IO::Socket::INET->new(ReuseAddr => '1',
    > LocalPort => '68',
    > Proto => 'udp') or die "can't bind:
    > $@\n";
    >
    > this dies with: "IO::Socket::INET: Address already in use"
    >
    > some ideas?
    >
    > thanx, hagen
    chatiman, Feb 20, 2004
    #2
    1. Advertising

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

    > "hagen" <> a écrit dans le message de news:
    > ...
    >> I try to write a dhcp-client to get user defined dhcp option.I'm
    >> stranding already with this reduced script:
    >>
    >> #!/usr/bin/perl
    >>
    >> use IO::Socket::INET;
    >>
    >> $sock = IO::Socket::INET->new(ReuseAddr => '1',
    >> LocalPort => '68',
    >> Proto => 'udp') or die "can't bind:
    >> $@\n";
    >>
    >>


    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 dies with: "IO::Socket::INET: Address already in use"

    > 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.


    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).

    HTH

    --
    Jim

    Copyright notice: all code written by the author in this post is
    released under the GPL. http://www.gnu.org/licenses/gpl.txt
    for more information.

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

    hagen Guest

    James Willmore <> wrote in message news:<>...
    > On Fri, 20 Feb 2004 16:42:03 +0100, chatiman wrote: [Don't top post - it's
    > rude]
    > [re-ordered to proper format]
    >
    > > "hagen" <> a écrit dans le message de news:
    > > ...
    > >> I try to write a dhcp-client to get user defined dhcp option.I'm
    > >> stranding already with this reduced script:
    > >>
    > >> #!/usr/bin/perl
    > >>
    > >> use IO::Socket::INET;
    > >>
    > >> $sock = IO::Socket::INET->new(ReuseAddr => '1',
    > >> LocalPort => '68',
    > >> Proto => 'udp') or die "can't bind:
    > >> $@\n";
    > >>
    > >>

    >
    > 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 dies with: "IO::Socket::INET: Address already in use"

    > > 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.

    >
    > 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).
    >


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

    bye,
    Hagen
    hagen, Feb 21, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bearish
    Replies:
    2
    Views:
    573
    J Berends
    Apr 8, 2005
  2. Magnus Lycka
    Replies:
    3
    Views:
    1,528
    Magnus Lycka
    May 31, 2005
  3. Tor Erik
    Replies:
    12
    Views:
    8,823
    Rhamphoryncus
    Sep 5, 2006
  4. Jean-Paul Calderone
    Replies:
    0
    Views:
    960
    Jean-Paul Calderone
    Jan 27, 2009
  5. AK
    Replies:
    5
    Views:
    1,509
Loading...

Share This Page