|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29576 Fsockopen function working incorrectly?
Submitted: 2004-08-09 02:25 UTC Modified: 2004-08-26 01:00 UTC
From: admin at php2tor dot com Assigned:
Status: No Feedback Package: Network related
PHP Version: 4.3.8 OS: Fedora Core 1
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2004-08-09 02:25 UTC] admin at php2tor dot com
I'm using Fedora Core 1 and PHP 4.3.8

I'm using the fsockopen function to check status of port for a windows environment. I'm going thru the WAN to check this port which is two hops away. For some reason I had a routing issue to the destination network. I tried to ping the server from my windows workstation and I would get reply from the router (as opposed to just getting a request timeout message) saying the destination network was unavailable. Anyway, when I ran the script that checks the server (from the fedora machine), the php script would report the server as up, when in reality it couldn't be reached.

I'm guessing cause the router respoded with reply messages that the fsockopen function assumes a connection is made? 

Reproduce code:
$host = '';
$port = '445';
$timeout = '2';

$fp = fsockopen($host, $port, $errno. $errstr, $timeout);

if ($fp)
    print 'server_up.gif';


  print 'server_down.gif';


Expected result:
Should show the host is not reachable and print "the device is down".

Actual result:
given the conditions mentioned above, the server should show down, but the fsockopen says its up.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-09 07:16 UTC]
Run this:

strace -e trace=network php yourscript.php

and paste the output here.

Also, please try running telnet from the fedora machine to that IP and port combo to see if it does the same thing.
 [2004-08-26 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Aug 23 22:01:28 2019 UTC