Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
After upgrading from Debian Lenny to Squeeze, I got my application exiting with this error:
Bad arg length for Socket::inet_ntoa, length is 16, should be 4 at /app/lib/HTTP/Daemon.pm line 48
The offending line is from HTTP/Daemon.pm is:
$url .= gethostbyaddr($addr, AF_INET) || inet_ntoa($addr);
$addr is returned by $self->sockaddr, and since HTTP::Daemon does not override this method, sockaddr() comes from its parent, IO::Socket::INET. From the number of bytes I'm guessing this is a IPv6/IPv4 thingy? If I print unpack("h*", $addr), it's just a bunch of \x00 though...
Anyway, I'm placing a workaround like this before line 48:
if (length($addr) == 16) { $addr = substr($addr, 12) }
My app now runs as usual, but I'm sure this is not proper. Any insights on why this is happening and how to properly solve this? Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: IO::Socket::INET's sockaddr() returns 16 byte instead of 4, Socket::inet_ntoa() complains
by ikegami (Patriarch) on Jan 20, 2012 at 22:42 UTC | |
by sedusedan (Pilgrim) on Jan 21, 2012 at 03:06 UTC | |
by Anonymous Monk on Feb 28, 2012 at 15:26 UTC | |
by sedusedan (Pilgrim) on Mar 06, 2012 at 02:08 UTC | |
|
Re: IO::Socket::INET's sockaddr() returns 16 byte instead of 4, Socket::inet_ntoa() complains
by VinsWorldcom (Prior) on Jan 20, 2012 at 21:12 UTC |