problems with fsockopen() on os x
Posted: Mon Apr 05, 2004 2:17 pm
Hi, I'm using Apache 1.3.x and PHP 4.x on my Mac OS X 10.3 system, and I am having a lot of trouble with the fsockopen() function. Basically I'm implementing a TrackBack system in PHP, and am sending a POST request to another url. Here's some basic test code I've written:
Basically in this case I'm pinging my own server, which happens to be running via Web Sharing in the system prefs app. Here is the error I get:
I have also tried this using my IP address in place of pcp....comcast.net and also localhost. Any suggestions are appreciated!
Thanks,
Kyle Bragger
Code: Select all
<?php
error_reporting(E_ALL);
ini_set('display_errors','on');
// build our request
$r = <<<REQ
POST /test/ping/ping.php?id=5 HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 4096
foo=bar&name=Tom+Smith&what=nothing
REQ;
// connect
echo '<h1 style="color: #0A0;font-family:Verdana;">Pinging site...</h1>';
$fp = fsockopen('http://'.$_SERVER['HTTP_HOST'],80);
if ($fp)
{
fputs($fp,$r);
// get response
while (!feof($fp))
{
$res .= fgets($fp,128);
}
echo $res;
fclose($fp);
}
?>Code: Select all
Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: No address associated with nodename in /Users/kylebragger/Sites/test/ping/index.php on line 15
Warning: fsockopen(): unable to connect to http://pcp01770159pcs.audubn01.nj.comcast.net:80 in /Users/kylebragger/Sites/test/ping/index.php on line 15Thanks,
Kyle Bragger