Page 1 of 1

fsockopen() Help

Posted: Fri Feb 27, 2009 10:46 pm
by xQuasar
Well, I'm using the following script to check whether or not a port of my server is open or not; but since the server whose post I'm checking and the webserver aren't the same, I'm getting the following error:

Code: Select all

Warning: fsockopen() [function.fsockopen]: unable to connect to [IP HERE]:8484 (Connection refused) in /home/xquasar/public_html/server.php on line 32
Here's my server.php script:

Code: Select all

<?php
if (eregi('server.php', $_SERVER['PHP_SELF'])) {
    echo "Error.";
} else {
    include 'mysql/login.php';
    include 'mysql/open.php';
 
    $serverip = "ip"; //ip
    $loginport = "8484";
    $sql_db = "odinms";
    $sql_host = "ip"; //ip
    $sql_user = "root";
    $sql_pass = ""; //mysql pass
    $offline = "<font size=2 color=red>OFFLINE</font>";
    $online = "<font size=2 color=green>ONLINE</font>";
    
    $link = mysql_connect($sql_host, $sql_user, $sql_pass);
    mysql_select_db($sql_db, $link);
 
    $result = mysql_query("SELECT * FROM accounts", $link);
    $num_rows_user = mysql_num_rows($result);
 
    $result2 = mysql_query("SELECT * FROM characters", $link);
    $num_rows_char = mysql_num_rows($result2);
    
    $pplOnline = mysql_query("SELECT * FROM accounts where loggedin = 1 OR loggedin = 2");
    $noOnline = mysql_num_rows($pplOnline);
    
    $cmsOnline = mysql_query("SELECT * FROM accounts where cmsloggedin = 1");
    $noCmsOnline = mysql_num_rows($cmsOnline);
 
        [b]$fp = fsockopen($serverip, $loginport, $errno, $errstr, 1);
 
        fclose($fp);
        $sql = mysql_connect($sql_host, $sql_user, $sql_pass)or die("Error on trying to connect in MySQL: " . mysql_error());
        mysql_select_db($sql_db)or die("Error on trying to connect in Database");[/b]
        
    include 'mysql/close.php';
}
?>
Is it because the server whose port I'm checking is blocking the connection, or what?