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

H

hagen

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
 
C

chatiman

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

James Willmore

On Fri, 20 Feb 2004 16:42:03 +0100, chatiman wrote: [Don't top post - it's
rude]
[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 :)
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
 
H

hagen

James Willmore said:
On Fri, 20 Feb 2004 16:42:03 +0100, chatiman wrote: [Don't top post - it's
rude]
[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 :)
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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top