jasemilly Posted July 10, 2012 Share Posted July 10, 2012 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; } } Quote Link to comment https://forums.phpfreaks.com/topic/265487-fsopen/ Share on other sites More sharing options...
xyph Posted July 10, 2012 Share Posted July 10, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/265487-fsopen/#findComment-1360652 Share on other sites More sharing options...
jasemilly Posted July 11, 2012 Author Share Posted July 11, 2012 I am passing a domain name, I shall have a play with it's IP address and disconecting the router and turning it off, thanks!!! Quote Link to comment https://forums.phpfreaks.com/topic/265487-fsopen/#findComment-1360721 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.