JS server connection check

Skilled Illusionist
Joined
May 28, 2006
Messages
364
Reaction score
0
Right, basically I need to know what little piece of code checks whether a connection is active. I have very little knowledge of JS, and I've googled through a lot of things but I haven't found anything related to this. I would appreciate some help.
 
An offline/offline server status. Yes it's meant for a webpage, but I'm not interested in using PhP. All I have is an IP and Port, no fancy things.
 
Last edited:
I have the scripts I need for this in PHP, but what exactly do I need to use PHP? I know very little about it you see...
 
Thanks, I'll try and get it running after I've made head or tails of all this stuff these websites say, they're so confusing...

Edit: I'm on the verge of giving up to be honest, this is ridiculous.
 
Last edited:
btw, there is that php code


PHP:
<?php 
$IP = array( 
"test1:" => "localhost:80", 
"test2:" => "192.168.0.31:80", 
); 

while(list($ServerName,$Host)=each($IP)) 
{ 
    list($IPAddress,$Port)=explode(":",$Host); 
    if($fp = @fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR_STR,5)) 
    { 
        fclose($fp); 
        echo "$ServerName @$IPAddress:$Port is Online<br>"; 
    } 
    else 
    { 
        echo "$ServerName @$IPAddress:$Port is Offline<br>"; 
    } 
} 
?>

Thanx to [lexx]
 
Thanks, I'll try and get it running after I've made head or tails of all this stuff these websites say, they're so confusing...

Edit: I'm on the verge of giving up to be honest, this is ridiculous.
...

You should only ever look at the official PHP site if you want the real accurate information. Everything else should be just a guideline.

To be honest, I just started "really" writing code in PHP several days ago... all you need is the manual, a text editor, and a webserver with PHP (preferably local) to experiment on. Not really hard, considering I've already written most of an account management system for Gunbound.
 
btw, there is that php code

Code:
Thanx to [lexx][/QUOTE]

Which is all in all a very neat script, prolly couldn't have written it better myself, but a lot more complicated then what the topicstarter needs I deem :) All he probably needs is this:

[php] echo fsockopen("ip.adres.here", port, $errno, $errstr, 2) ? 
    "Server is online!" : "Server is offline!"; [/php]

With the values filled in for my webserver this becomes:

[php]echo fsockopen("fragfrog.nl", 80, $errno, $errstr, 2) ?
    "Server is online!" : "Server is offline!";[/php]

If it tends to state a server is offline when really it isn't, increase the last number (the 2) to a bigger value - this is the timeout in seconds, and sometimes a server fails to respond within the time given. Do note that if you increase it a lot people loading your page will also have to wait for that amount of time. Ie, if you set it to be 30 instead of 2 and a server is offline, people will need to wait 30 seconds before the page continues loading. There are ways around this, but not neat or simple ones as far as I know :smile:
 
Thanks a lot, I'm just trying to find a webserver with PHP now, I'm not good with webservers ya see...

Edit: I can't find what I need on the official site.
 
Last edited:
AppServNetwork - apache2.2, mysql5, php5, phpmyadmin 2.9 :tongue:

I would not succest Apache 2.2, it is most unstablest apache done, at lleast for windows platform

Instead of Apache 2.2 i would succest apache 1.3 or 2.0...

Apache Friends - Apache 2, MySQL5, PHP 5.2.0 + 4.4.4 + PEAR, Openssl 0.9.8d, phpMyAdmin 2.9.1.1, SQLite 2.8.15, ADODB 4.93, Zend Optimizer 3.0.2, XAMPP Security Check (Get the older version with Apache 2 from sourceforge.)
 
Last edited:
Back