Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.2.2

Bug #18231 IPv6 sockets cannot be used
Submitted: 2011-02-01 22:20 UTC
From: dyonisius Assigned: doconnor
Status: Closed Package: Net_Socket (version 1.0.10)
PHP Version: 5.2.4 OS: Ubuntu 8.04
Roadmaps: (Not assigned)    
Subscription  


 [2011-02-01 22:20 UTC] dyonisius (Dyonisius Visser)
Description: ------------ Using connect() with a numerical IPv6 address does not work. This is because such addresses contain a colon, which is not in recognized as an IP address. Instead, it is treated as a hostname. This will be tried to resolve, which of course also fails. This patch checks for the colon, and if found puts brackets around the address: --- /usr/share/php/Net/Socket.php 2011-02-01 14:32:50.000000000 +0100 +++ Socket.php 2011-02-01 17:14:27.000000000 +0100 @@ -122,9 +122,9 @@ if (!$addr) { return $this->raiseError('$addr cannot be empty'); - } elseif (strspn($addr, '.0123456789') == strlen($addr) || + } elseif (strspn($addr, ':.0123456789') == strlen($addr) || strstr($addr, '/') !== false) { - $this->addr = $addr; + $this->addr = substr($addr, ':') ? '['.$addr.']' : $addr; } else { $this->addr = @gethostbyname($addr); }

Comments

 [2011-02-01 22:30 UTC] dyonisius (Dyonisius Visser)
Please note that this patch ONLY makes numerical IPv6 addresses work. Using IPv6 host names will not work until http://bugs.php.net/bug.php?id=49493 is fixed.
 [2013-04-15 12:09 UTC] alec (Aleksander Machniak)
Why this obvious bug is still not fixed?
 [2013-05-15 14:32 UTC] doconnor (Daniel O'Connor)
-Status: Open +Status: Closed -Assigned To: +Assigned To: doconnor
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.