douduan1953 2012-04-18 10:53
浏览 105

奇怪的行为:使用FSockopen的Apache PHP Windows

Consider this simple code:

 <?php
   error_reporting(E_ALL);
   //error_reporting(E_STRICT);
   date_default_timezone_set('Asia/Calcutta');
   $smtp_server = fsockopen("onelocalserver.com", 25, $errno, $errstr, 120);
   if(!$smtp_server)
     {
  // We have an error, do something
  echo " Error found! <br>$errno <br>$errstr";
  exit;
     }
  ?>

On Windows XP + php5.3.8 + apache 2.2, i get an error: Warning: fsockopen(): unable to connect to onelocalserver.com:25 (No connection could be made because the target machine actively refused it. )

However, on the same system where Apache and PHP are installed, if i run php from the command prompt ex: c:\php\php.exe filename.php (where above code is in the filename), then i don't get the error!

The server onelocalserver.com is listening on port 25 : there is an SMTP server running there.

Any ideas? This is really bizzare

Thanks in advance

  • 写回答

1条回答 默认 最新

  • dsdt66064367 2012-04-19 12:48
    关注

    After several tries with different IP addresses, i realised that the only problem was with fsockopen on port 25. It works well with command line interface but didn't work through the web browser. PHP was earlier installed in windows as CGI. I thought i will see if it still doesn't work when set up as an Apache handler and it works! http://www.php.net/manual/en/install.windows.apache2.php .

    Hope this helps someone!

    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程