fsockopen() fails in script run by IIS
| From: | Evan Burkitt | Date: | Sat, 09 Feb 2008 00:21:18 +0000 |
| Subject: | fsockopen() fails in script run by IIS | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-28774@lists.php.net to get a copy of this message | ||
I'm using IIS 6.0 on Windows 2003 server. There is a POP3 server running on
the machine at port 110. When I run the following script in a browser (that
is, through IIS) it reports "Could not connect to localhost at port 110
($errno=12; $errstr=)". When I run it from a command prompt on the server
the connection succeeds and the script reports "Socket connection
established". The connection succeeds even when I run cmd.exe as the
Internet guest user, which is the account IIS runs scripts under.
Any ideas as to what's going on?
-Evan
-----
<?php
$host = "localhost";
$port = "110";
?>
<html>
<h1>Attempting to open socket on host '<?php echo ("$host")?>' at port '<?php echo ("$port")?>'</h1>
<h2>
<?php
$errno = 0;
$errstr = "<no error reported>";
$fp = @fsockopen($host, $port, $errno, $errstr);
if ($fp) {
echo "Socket connection established";
fclose($fp);
}else {
echo "Could not connect to $host at port $port (\$errno=$errno;
\$errstr=$errstr)";
}
?>
</h2>
</html>