奇怪的行为:使用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

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!