fsockopen() unable to connect
Posted by: nbakewell (---.ntc.harrisonburg.shentel.net)
Date: January 26, 2008 11:31PM

Hey,

I am trying to run a piece of code on my machine with WAMP that I had running on my server, but I am now getting an error. I am guessing that I have to change some setting, but I don't know which one or where to find it. Here is the error:

Warning: fsockopen() [function.fsockopen]: unable to connect to [google.com] (Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?) in C:\www\www\Snippets\systest.php on line 40


And my code is:

function pingDomain($domain){
$starttime = microtime(true);
$file = fsockopen ($domain, 80, $errno, $errstr, 10);
$stoptime = microtime(true);
$status = 0;

if (!$file) $status = -1; // Site is down
else {
fclose($file);
$status = ($stoptime - $starttime) * 1000;
$status = floor($status);
}
return $status;
}


Any ideas? Thanks!

Options: ReplyQuote
Re: fsockopen() unable to connect
Posted by: tantaris (---.nga.mil)
Date: February 13, 2008 05:25PM

In the php.ini, you need to ensure that the line:
extension=php_sockets.dll
is not commented out (it is by default).

Good luck!

Options: ReplyQuote


Sorry, only registered users may post in this forum.