#48131 [Asn->Csd]: stream_context_create / bindto not working with IPv4 on a dual IPv4/IPv6 system
| From: | iliaa@php.net | Date: | Mon, 04 May 2009 14:46:38 +0000 |
| Subject: | #48131 [Asn->Csd]: stream_context_create / bindto not working with IPv4 on a dual IPv4/IPv6 system | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-136733@lists.php.net to get a copy of this message | ||
ID: 48131
Updated by: iliaa@php.net
Reported By: dvasseur at diway dot net
-Status: Assigned
+Status: Closed
Bug Type: Streams related
Operating System: Linux - Ubuntu 8.10
PHP Version: 5.*, 6CVS (2009-05-02)
Assigned To: iliaa
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2009-05-02 19:30:50] dvasseur at diway dot net
Same bug with CVS snapshot
--
PHP 5.2.10-dev (cli) (built: May 2 2009 21:22:25)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
--
------------------------------------------------------------------------
[2009-05-02 13:30:45] dvasseur at diway dot net
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 this bug report at http://bugs.php.net/?id=48131&edit=1