Skip to content

Commit

Permalink
Use AF_UNSPEC as the default family in IO::Socket::INET
Browse files Browse the repository at this point in the history
Now that IO::Socket::INET actually sets the family of a socket given the
one passed to .new, the default needs to be changed to AF_UNSPEC rather
than AF_INET to maintain compatibility with older code.
  • Loading branch information
Kaiepi committed Aug 19, 2019
1 parent 207b825 commit d7d8d37
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/core/IO/Socket/INET.pm6
Expand Up @@ -19,10 +19,12 @@ my class IO::Socket::INET does IO::Socket {
has Int $.localport;
has Int $.backlog;
has Bool $.listening;
has $.family = nqp::const::SOCKET_FAMILY_INET;
has $.family = nqp::const::SOCKET_FAMILY_UNSPEC;
has $.proto = PIO::PROTO_TCP;
has $.type = PIO::SOCK_STREAM;

# XXX: this could be a bit smarter about how it deals with unspecified
# families...
my sub split-host-port(:$host is copy, :$port is copy, :$family) {
if ($host) {
my ($split-host, $split-port) = $family == nqp::const::SOCKET_FAMILY_INET6
Expand Down Expand Up @@ -56,9 +58,10 @@ my class IO::Socket::INET does IO::Socket {
Str :$localhost is copy,
Int :$localport is copy,
Int :$family where {
$family == nqp::const::SOCKET_FAMILY_INET
$family == nqp::const::SOCKET_FAMILY_UNSPEC
|| $family == nqp::const::SOCKET_FAMILY_INET
|| $family == nqp::const::SOCKET_FAMILY_INET6
} = nqp::const::SOCKET_FAMILY_INET,
} = nqp::const::SOCKET_FAMILY_UNSPEC,
*%rest,
--> IO::Socket::INET:D) {

Expand All @@ -81,9 +84,10 @@ my class IO::Socket::INET does IO::Socket {
Str:D :$host! is copy,
Int :$port is copy,
Int :$family where {
$family == nqp::const::SOCKET_FAMILY_INET
$family == nqp::const::SOCKET_FAMILY_UNSPEC
|| $family == nqp::const::SOCKET_FAMILY_INET
|| $family == nqp::const::SOCKET_FAMILY_INET6
} = nqp::const::SOCKET_FAMILY_INET,
} = nqp::const::SOCKET_FAMILY_UNSPEC,
*%rest,
--> IO::Socket::INET:D) {

Expand Down

0 comments on commit d7d8d37

Please sign in to comment.