lpglycerine Posted October 10, 2008 Share Posted October 10, 2008 Hi, I've been dealing with this issue for about 6 hours now and I'm ready to this stupid computer out the window. I have two computers that I use to test my php scripts, with two separate ISP's so I can check locally (192.168.1.10) and check remotely (www.ourstream.net) All I'm trying to do is check if a certain port is open on my web server. So, I use fsockopen() to check.. and it works on the local machine, but not on the remote machine. I cannot find what is wrong with my code I have tried everything. If I check on the remote computer to see if port 80 is open on 'www.google.com', it will succeed! If I check to see if port 80 is open on 'www.ourstream.net' it will fail. please please help .... <?php $site = $_SERVER['HTTP_HOST']; $port = 80; $fp = @fsockopen($site, $port, $errno, $errstr, 10); if(!$fp){ echo "<b>The port is NOT open!</b>"; }else{ echo "<b>The port is open!</b>"; fclose($fp); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/127788-fsockopen-wont-open-urlport-of-current-web-server/ Share on other sites More sharing options...
lpglycerine Posted October 10, 2008 Author Share Posted October 10, 2008 has anyone ever experienced this problem? or can test it to see if they have the same problem on their setup? Quote Link to comment https://forums.phpfreaks.com/topic/127788-fsockopen-wont-open-urlport-of-current-web-server/#findComment-661556 Share on other sites More sharing options...
Asheeown Posted October 10, 2008 Share Posted October 10, 2008 Try this: <?php $site = gethostbyname($_SERVER['HTTP_HOST']); $port = 80; $fp = @fsockopen($site, $port, $errno, $errstr, 10); if(!$fp){ echo "<b>The port is NOT open!</b>"; }else{ echo "<b>The port is open!</b>"; fclose($fp); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/127788-fsockopen-wont-open-urlport-of-current-web-server/#findComment-661562 Share on other sites More sharing options...
redarrow Posted October 10, 2008 Share Posted October 10, 2008 url read: http://uk3.php.net/fsockopen try this aswell <?php $fp = fsockopen("www.google.com", 80, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { $out = "GET / HTTP/1.1\r\n"; $out .= "Host: www.google.com\r\n"; $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); while (!feof($fp)) { echo fgets($fp, 128); } fclose($fp); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/127788-fsockopen-wont-open-urlport-of-current-web-server/#findComment-661563 Share on other sites More sharing options...
redarrow Posted October 10, 2008 Share Posted October 10, 2008 Can u tell us what ur doing please.......... USING TCP 30 NOT TCP 10 function works this way... <?php $site = "www.google.com";//works //$site = "www.goggle.com";//dont work unknown url non existent $port = 80; $fp = fsockopen($site, $port, $errno, $errstr, 30); if(!$fp){ echo "<b>The port is NOT open!</b>"; }else{ echo "<b>The port is open!</b>"; fclose($fp); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/127788-fsockopen-wont-open-urlport-of-current-web-server/#findComment-661582 Share on other sites More sharing options...
lpglycerine Posted October 10, 2008 Author Share Posted October 10, 2008 I just tried both suggestions and they both result in the same error. google.com will return true whereas the current website address will time out and give the following error... ----- Warning: fsockopen() [function.fsockopen]: unable to connect to www.ourstream.net:80 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in C:\... Fatal error: Maximum execution time of 30 seconds exceeded in C:\... Quote Link to comment https://forums.phpfreaks.com/topic/127788-fsockopen-wont-open-urlport-of-current-web-server/#findComment-661585 Share on other sites More sharing options...
corbin Posted October 10, 2008 Share Posted October 10, 2008 Hrmmm... What exactly does ourstream.net resolve to? Why not just use localhost? Quote Link to comment https://forums.phpfreaks.com/topic/127788-fsockopen-wont-open-urlport-of-current-web-server/#findComment-661593 Share on other sites More sharing options...
lpglycerine Posted October 10, 2008 Author Share Posted October 10, 2008 oh my god it works with localhost!!!!!! =) thank you soooo much! Quote Link to comment https://forums.phpfreaks.com/topic/127788-fsockopen-wont-open-urlport-of-current-web-server/#findComment-661596 Share on other sites More sharing options...
corbin Posted October 10, 2008 Share Posted October 10, 2008 Uh.... no prob I guess. Quote Link to comment https://forums.phpfreaks.com/topic/127788-fsockopen-wont-open-urlport-of-current-web-server/#findComment-661598 Share on other sites More sharing options...
redarrow Posted October 10, 2008 Share Posted October 10, 2008 your tieland host is a bit crapy mate there dns is well mashed lol........ <?php $site = "202.149.98.245"; $port = 80; $fp = fsockopen($site, $port, $errno, $errstr, 30); if(!$fp){ echo "<b>The port is NOT open!</b>"; }else{ echo "<b>The port is open!</b>"; fclose($fp); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/127788-fsockopen-wont-open-urlport-of-current-web-server/#findComment-661602 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.