Skip Menu |
 

This queue is for tickets about the IO-Socket-INET6 CPAN distribution.

Report information
The Basics
Id: 81125
Status: open
Priority: 0/
Queue: IO-Socket-INET6

People
Owner: Nobody in particular
Requestors: BBYRD [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Add new hostport methods
Download (untitled) / with headers
text/plain 1012b
Since IPv4 and IPv6 have different formats for host/port combos, this should be normalized to a single method for handling both. The methods below should handle all cases of host/port/scope for both domain models. sub sockhostport { @_ == 1 or croak 'usage: $sock->sockhostport()'; my ($sock) = @_; return undef unless (my $host = $sock->sockhost); if ($sock->sockdomain == AF_INET6) { my $s = $sock->sockscope; $s = $s ? sprintf('%%%u', $s) : ''; return sprintf('[%s%s]:%u', $host, $s, $sock->sockport); } return sprintf('%s:%d', $host, $sock->sockport); } sub peerhostport { @_ == 1 or croak 'usage: $sock->peerhostport()'; my ($sock) = @_; return undef unless (my $host = $sock->peerhost); if ($sock->sockdomain == AF_INET6) { my $s = $sock->peerscope; $s = $s ? sprintf('%%%u', $s) : ''; return sprintf('[%s%s]:%u', $host, $s, $sock->peerport); } return sprintf('%s:%d', $host, $sock->peerport); }
Download (untitled) / with headers
text/plain 535b
Hi Brendan, On Mon Nov 12 13:08:55 2012, BBYRD wrote: Show quoted text
> Since IPv4 and IPv6 have different formats for host/port combos, this > should be > normalized to a single method for handling both. The methods below > should handle > all cases of host/port/scope for both domain models. >
Looks good. Can you provide a pull request for that with POD documentation for both functions? See: https://bitbucket.org/shlomif/perl-io-socket-inet6 Also note that IO::Socket::IP may be preferable over IO::Socket::INET6. Regards, -- Shlomi Fish


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.