php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: admin at php2tor dot com
New email:
PHP Version: OS:

 

 [2004-08-09 02:25 UTC] admin at php2tor dot com
Description:
------------
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 = '192.168.1.1';
$port = '445';
$timeout = '2';

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

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

}else{

  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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-09 07:16 UTC] wez@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 19:01:28 2024 UTC