|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-03-05 17:59 UTC] scott at abcoa dot com
Description:
------------
I had no trouble with the fsockopen() until I upgraded to PHP 4.3.4. My last working version was 4.2.3 before the upgrade. It sure look like a fsockopen() issue. Enclosed below is the source code that produce the same error result with both the Apache/Browser and the Shell Environment. I tried variety of URL Address and still get the same result, like www.google.com, www.cnn.com, www.php.net, etc... Been trying different ways with the scripts, machine and network and yet get the same result. I tried with and without the "tcp:\\" and still get the same result. (One more thing, could error 66 meant 6 with an one digit, not two??)
Reproduce code:
---------------
<?
//fsockopen("tcp:\\www.google.com",80,$errno,$errstr,30);
fsockopen("www.google.com",80,$errno,$errstr,30);
echo "\n\n";
echo $errno."\n\n";
echo $errstr."\n\n";
?>
Expected result:
----------------
Should expect to see an successful connection to www.google.com
Actual result:
--------------
Warning: fsockopen() [http://www.php.net/function.fsockopen]: php_hostconnect: connect failed in <<file path omitted by me>> on line 5
Warning: fsockopen() [http://www.php.net/function.fsockopen]: unable to connect to www.google.com:80 in <<file path omitted by me>> on line 5
66
Addr family not supported by protocol
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 26 03:00:01 2025 UTC |
I'm also concerned that you may not actually be testing against 4.3... One of the error messages you noted in your original report "php_hostconnect: connect failed in ..." only appears in PHP >prior< to version 4.3.0. As of the 4.3 branch that message contains noticably different text. This discrepency doesn't necessary speak to the fact that the error is occuring. But it raises a question as to whether there are "lingering ghosts" of the prior version. Perhaps creating a conflict with 4.3 which leads to the emergence of the error. Can you conirm that (after the copious number of recompiles you've been asked for) you're still getting that specific error message in your output? It'd also be interresting to see if the sockets extension behaves in the same way: <?php $socket = socket_create(AF_INET, SOCK_STREAM, 0); var_dump($socket); var_dump(socket_connect($socket, 'www.google.com', 80)); ?> or (for a slight variation: <?php $socket = socket_create(AF_INET, SOCK_STREAM, getprotobyname("tcp")); var_dump($socket); var_dump(socket_connect($socket, 'www.google.com', 80)); ?> Of course, you'll need to ./configure --enable-sockets in order to try these tests.Sorry, I wanted you to run a test with fsockopen(), not the socket_* extension. (Believe it or not they're completely different implementations even though they do the same thing) <?php $fp = fsockopen('www.exmaple.com', 80); ?> Please run that one against the version you've already patched and compiled.Here's the response I got... It's also the same with the host, "www.example.com" instead of "www.google.com". --snip-- Content-type: text/html X-Powered-By: PHP/4.3.5RC4-dev !#/usr/local/bin/php getaddresses GETADDRINFO method defaulting to AF_INET(2) hints.ai_family = 0 got result sai->ai_family = 2 returning from getaddresses: n = 1 php_network_getaddresses returned 1 Creating socket of type 0 (AF_INET = 2) socket() returned: -1 <br /> <b>Warning</b>: fsockopen(): unable to connect to www.google.com:80 in <b>/home/website/emarket/test_fsockopen_shell.sh</b> on line <b>6</b><br /> 66 Addr family not supported by protocol --snip--