fsockopen Not Working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nic9
Forum Newbie
Posts: 5
Joined: Sun Sep 21, 2003 4:12 am

fsockopen Not Working

Post by nic9 »

I am trying to use fsockopen() in PHP and But it's giving me an error. I have tried it on both Windows IIS and Linux redhad 7.3 and Safe Mode is Off but both are unable to connect to any URL.

$fp = fsockopen("http://www.abc.com", "80");

as soon as this code executes it gives me following error:


Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known (is your IPV6 configuration correct? If this error happens all the time, try reconfiguring PHP using --disable-ipv6 option to configure) on line 3

Warning: fsockopen(): unable to connect to http://www.abc.com:80 on line 3

Anybody know why the error is coming
nic9
Forum Newbie
Posts: 5
Joined: Sun Sep 21, 2003 4:12 am

Post by nic9 »

No, one knows ???
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

there is a bug report with similar symptoms at http://bugs.php.net/bug.php?id=7880
Do you use the most recent version of php?
kylebragger
Forum Newbie
Posts: 7
Joined: Thu Feb 26, 2004 6:02 am

Re: fsockopen Not Working

Post by kylebragger »

i get the same error (minus the text about ipv6)
nic9 wrote:I am trying to use fsockopen() in PHP and But it's giving me an error. I have tried it on both Windows IIS and Linux redhad 7.3 and Safe Mode is Off but both are unable to connect to any URL.

$fp = fsockopen("http://www.abc.com", "80");

as soon as this code executes it gives me following error:


Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known (is your IPV6 configuration correct? If this error happens all the time, try reconfiguring PHP using --disable-ipv6 option to configure) on line 3

Warning: fsockopen(): unable to connect to http://www.abc.com:80 on line 3

Anybody know why the error is coming
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Code: Select all

<?
 //try this to see if this works..

$page = '';
$fh = fopen("http://www.abc.com/example.txt , 'r')
  or die ($php_errormsg);

while(! feof($fh)) {
  $page .= fread($fh,1048576
}
fclose($fh);
?>
Post Reply