SOHO : Small Office Home Office
Freeware - Opensource software tips, tricks, tweaks & fixes for managing, securing, improving the performance of SOHO Desktop, Laptop, Networks

Sunday, May 22, 2011

How to Show if your server is Online or Offline?

One way to try to find out if a server is online is to try and open a socket connection to the server. If the connection fails, one can assume that the server is down (although the problem can be somewhere else too).

Check out this function and read all the user comments:

Here's a very simple demonstration of php code:
<?php if (fsockopen('', 80)){     
'The server in online');  

} else{  
'The server in offline');  
The first parameter is the IP address of the server you want to check (in this case,, it could also be something like 111.222.333.444). The 80 is the port number (for HTTP), which can sometimes be different (21 for FTP etc.).

No comments:

Post a Comment