fsockopen on ssl://
| From: | bob pilly | Date: | Tue, 13 May 2008 19:53:17 +0000 |
| Subject: | fsockopen on ssl:// | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-274271@lists.php.net to get a copy of this message | ||
Hi all
I have tried researching this issue but havent come up with any solution so im hoping someone has
seen it before and can help. I have the following test script that uses fsockopen to connect to a
https site, get the contents and outputs it.
<?php
$host = "www.microsoft.com";
$path = "/";
$fh = fsockopen("ssl://".$host, 443, $errno, $errstr, 5);//opens url for reading with a
timeout of 2 seconds
if (!$fh){
echo "FAIL: $errno $errstr ";
}
else{
$out = "GET $path HTTP/1.1\r\n";
$out .= "Host: $host\r\n";
$out .= "Connection: Close\r\n";
$out .= "\r\n";
fwrite($fh, $out);
stream_set_timeout($fh,2);
$info = stream_get_meta_data($fh);
if($info['timed_out']){
echo "TIMEOUT\n";
}
else{
$haystack = "";
while (!feof($fh)) {
$haystack.= fgets($fh, 4096);
}
}
print $haystack;
fclose($fh);
}
?>
if i run this script using php -f test.php it works fine. However if i try and run this on my loca
apache server i get the following error:
Warning: fsockopen() [function.fsockopen]:unable to connect to ssl://www.microsoft.com:443 (A
connection attemptfailed because the connected party did not properly respond after aperiod of time,
or established connection failed because connected hosthas failed to respond.) in C:\Program
Files\Apache Software Foundation\Apache2.2\htdocs\test.php on line 4
FAIL: 10060 A connection attempt failed because the connected party didnot properly respond after a
period of time, or established connectionfailed because connected host has failed to respond.
As you can see from that error i am using windows and apache 2.2. My php version is 5.25. I have
Registered Stream Socket Transports tcp, udp, ssl, sslv3, sslv2, tlsin my config.
Thanks for any help in advance and it is greatly appreciated, this problem is driving me nuts!!
Cheers
Bob
__________________________________________________________
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html