Jump to content

Recommended Posts

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);

}

?>

 

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);
}
?>

 

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);
}
?>

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);
}

?>

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:\...

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);
}
?>

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.