php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50415 stream_socket_client() IPv6 issues
Submitted: 2009-12-08 20:15 UTC Modified: 2009-12-16 01:00 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mbeeching at btinternet dot com Assigned:
Status: No Feedback Package: Network related
PHP Version: 5.2.11 OS: FreeBSD 7.0
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
47 - 37 = ?
Subscribe to this entry?

 
 [2009-12-08 20:15 UTC] mbeeching at btinternet dot com
Description:
------------
OK, firstly, without a context paramter specifying a bindto, stream_socket_client() fails to connect to IPv6 IP's with the following warning:
Warning: stream_socket_client(): unable to connect to tcp://[2001:470:1f09:11c:6d6b:7061:7373:7764]:6667 (Unknown error) in /usr/home/jobe/working/php/test.php on line 8

Secondly when you use a stream context as returned by stream_context_create() to specify an IPv6 IP or :: (the 0 of IPv6) address and port to bind a client connection, stream_socket_client() always responds with the following warning:
Warning: stream_socket_client(): failed to bind to '2001:470:1f09:11c:0:0:6a6f:6265:0', system said: Can't assign requested address in /usr/home/jobe/working/php/test.php on line 8

Now I can confirm the IPv6 address 2001:470:1f09:11c::6a6f:6265 IS available on a local interface as I have other applications using it. Also the connection IS established, but is NOT bound to the IPv6 IP specified.

Reproduce code:
---------------
For first issue:

$fp = stream_socket_client("tcp://[2001:470:1f09:11c:6d6b:7061:7373:7764]:6667", $errno, $errstr, 30);
if (!$fp) {
        die("$errstr ($errno)\n");
}

For second issue:
$opts = array('socket' => array('bindto' => '[2001:470:1f09:11c::6a6f:6265]:0'));
$ctx = stream_context_create($opts);

$fp = stream_socket_client("tcp://[2001:470:1f09:11c:6d6b:7061:7373:7764]:6667", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $ctx);
if (!$fp) {
        die("$errstr ($errno)\n");
}


Expected result:
----------------
For the first issue I expect stream_socket_client() to successfully connect to the IPv6 IP specified binding to [::]:0 in the same way it binds to 0:0 for IPv4

For the second issue I expect stream_socket_client() to successfully connect to the IPv6 IP specified binding to the context's IPv6 IP specification.

Actual result:
--------------
For the first issue no connection is established and a warning is issued.

For the second issue a warning is issued, the connection is established, but is not bound to the IPv6 IP specified.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-08 21:54 UTC] jani@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-12-09 08:26 UTC] mbeeching at btinternet dot com
OK thank you, that solves the first of the 2 issues but for the second I still receive the "failed to bind to" warning:

[jobe@alpha ~/working/php]$ php -v
PHP 5.2.12RC4-dev (cli) (built: Dec  9 2009 08:16:56)
<-- snip -->
[jobe@alpha ~/working/php]$ php test.php
Warning: stream_socket_client(): failed to bind to '2001:470:1f09:11c::6a6f:6265:0', system said: Can't assign requested address in /usr/home/jobe/working/php/test.php on line 8
 [2009-12-16 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 06:01:29 2024 UTC