Showing posts with label technical. Show all posts
Showing posts with label technical. Show all posts

Friday, March 19, 2010

How to check the status of server/host using PHP ?

Recently I came across this trivial problem of checking whether a server is ONLINE or OFFLINE. I tried "Ping" command but the following approach was more elegant.



$host = "127.0.0.1"; // could be any host address 
$port = "80"; //  port you wanna check 

$fp = @fsockopen($host, $port, $errno, $errstr, 2);

if (!$fp) {
echo "DEAD";


else { 
echo "ALIVE";
}


?>

Have fun !

Saturday, December 26, 2009

Port conflicts by Skype



Hi,
It seems a very trivial problem that when 2 programs try running on the same port numbers, they conflict with each other. I came across this problem when my Apache Server stopped working. The culprit was Skype. I installed Skype recently and as far as I knew, it used its own unique port number. But, as I delved further, I found that Skype also uses port 80 (which is default port for almost all HTTP servers) and port 443 as alternate ports :O.

To solve this, Open Skype --> Tools --> Options --> Advanced --> Connection --> Uncheck the use of port 80 and 443 as alternate ports.