From: dvasseur at diway dot net Operating system: Linux - Ubuntu 8.10 PHP version: 5.2.9 PHP Bug Type: Streams related Bug description: stream_context_create / bindto not working with IPv4 on a dual IPv4/IPv6 system
Description: ------------ My system has 2 ip addresses, one ipv4 (A.B.C.D) and the other ipv6 (1:2:3:4:5:6) I'm trying to open a file over HTTP (http://other.server/my.file.dat), 'other.server' is resolving both on ipv4 and ipv6 too. I'd like to choose wether IPv4 or IPv6 to open the file so I'm using stream_context_create() with the 'bindto' option. 'bindto' with an ipv4 address is NOT working 'bindto' with an ipv6 address is working Reproduce code: --------------- The following code is working (ipv6 is used) -- $opts = array( 'socket' => array( 'bindto' => '[1:2:3:4:5:6]:0', ), ); $context = stream_context_create($opts); $contents = file_get_contents('http://other.server/my.file.dat', FALSE, $context); -- The following code is NOT working: -- $opts = array( 'socket' => array( 'bindto' => 'A.B.C.D:0', ), ); $context = stream_context_create($opts); $contents = file_get_contents('http://other.server/my.file.dat', FALSE, $context); -- => PHP Warning: file_get_contents(): Invalid IP Address: A.B.C.D Expected result: ---------------- ipv4 working Actual result: -------------- ipv4 NOT working -- Edit bug report at http://bugs.php.net/?id=48131&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48131&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48131&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48131&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48131&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48131&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48131&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48131&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48131&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48131&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48131&r=support Expected behavior: http://bugs.php.net/fix.php?id=48131&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48131&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48131&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48131&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48131&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48131&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48131&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48131&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48131&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48131&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48131&r=mysqlcfg
