Hi,
I have some code which currently looks as follows:
sub url
{
my $self = shift;
my $url = $self->_default_scheme . "://";
my $addr = $self->sockaddr;
if (!$addr || $addr eq INADDR_ANY) {
require Sys::Hostname;
$url .= lc Sys::Hostname::hostname();
}
else {
$url .= gethostbyaddr($addr, AF_INET) || inet_ntoa($addr);
}
my $port = $self->sockport;
$url .= ":$port" if $port != $self->_default_port;
$url .= "/";
$url;
}
I am wanting to ensure that it supports IPv6, so I was looking to
modify the else statement, so that it reads somewhere along the lines:
else {
if ( isipv6($addr) ) {
$url .= "[";
$url .= inet_ntop(AF_INET6, $addr);
$url .= "]"
}
else {
$url .= gethostbyaddr($addr, AF_INET) || inet_ntoa($addr);
}
}
The problem is I am not sure how to tell whether the addrss is IPv4 or
IPv6. Any suggestions would be appreciated.
Thanks in advance
Andre
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/