PHP :: Bug #48131 :: stream_context_create
| Bug #48131 | stream_context_create / bindto not working with IPv4 on a dual IPv4/IPv6 system | ||||
|---|---|---|---|---|---|
| Submitted: | 2009-05-02 13:30 UTC | Modified: | 2009-05-04 14:46 UTC | ||
| From: | dvasseur at diway dot net | Assigned: | iliaa (profile) | ||
| Status: | Closed | Package: | Streams related | ||
| PHP Version: | 5.*, 6CVS (2009-05-02) | OS: | Linux - Ubuntu 8.10 | ||
| Private report: | No | CVE-ID: | None | ||
[2009-05-02 13:30 UTC] 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
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2009-05-02 19:30 UTC] dvasseur at diway dot net
[2009-05-04 14:46 UTC] iliaa@php.net