Jump to content

fsopen


jasemilly

Recommended Posts

just playing with this function and wanting to use on my page, even when I have disconected my router from the wall socket and run the function it still returns true.  I would expect it to be false.

 

 

function ping($host,$port=80,$timeout=6)

{

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

        if ( ! $fsock )

        {

                return FALSE;

        }

        else

        {

                return TRUE;

        }

}

Link to comment
Share on other sites

Are you giving it a domain, or an IP address?

 

Your computer might be returning a error page, which could result in the function returning true. Try using an IP range you know doesn't exist. 10.234.0.1

 

For example, if you use OpenDNS, by default it gives you a custom error page. This could result in a TRUE return regardless.

 

I'm housesitting at the moment, and they have the default Shaw ISP error messages come up, but it only does so when I prefix domains with www.

 

ping('argaergae.com') returns FALSE here, but ping('www.argaergae.com') returns TRUE. From my home connection, neither would return true because I don't have that sort of response to unreachable hosts.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.