Reply
Checking if server on or off. Help with stoping error message if it is off.
Old 05-04-2006, 01:37 PM Checking if server on or off. Help with stoping error message if it is off.
mad_willsy's Avatar
Super Spam Talker

Posts: 774
Name: Will Craig
Location: Cheltenham, Gloucestershire, UK
I have an apache server set up on my computer.
To save bw, if this computer is on, images etc are to be called from this computer.
I know how to do this, but not how to check if computer is on.
I have made file server.ison and have found the following that works...
PHP Code:
<?php
$off 
"No";
fopen("http://86.128.132.191/server.ison""r") or die($off "Yes");
echo 
$off;
?>
But, if i stop acache (simulating the computer being off) the error message
Warning: fopen(http://86.128.132.191/server.ison): failed to open stream: HTTP request failed! HTTP/1.1 200 OK in /home/thebulls/public_html/server.php on line 3 appears.

Basicly, what I am asking is: How do I stop error message appearing?
__________________
Wont :P
SoldierExteme.com - Free MMORPG - sign-up today!
Backthebulls.com - Free online games

Last edited by mad_willsy : 05-04-2006 at 01:39 PM. Reason: Title too long
mad_willsy is offline
Reply With Quote
View Public Profile Visit mad_willsy's homepage!
 
When You Register, These Ads Go Away!
Old 05-04-2006, 01:55 PM Re: Checking if server on or off. Help with stoping error message if it is off.
Christopher's Avatar
Iced Cap

Posts: 3,111
Location: Toronto, Ontario
You can suppress error messages by using the @ operator:
PHP Code:
@fopen(..... 
Christopher is offline
Reply With Quote
View Public Profile Visit Christopher's homepage!
 
Old 05-04-2006, 01:57 PM Re: Checking if server on or off. Help with stoping error message if it is off.
mad_willsy's Avatar
Super Spam Talker

Posts: 774
Name: Will Craig
Location: Cheltenham, Gloucestershire, UK
How do i add timeout?
__________________
Wont :P
SoldierExteme.com - Free MMORPG - sign-up today!
Backthebulls.com - Free online games
mad_willsy is offline
Reply With Quote
View Public Profile Visit mad_willsy's homepage!
 
Old 05-04-2006, 02:07 PM Re: Checking if server on or off. Help with stoping error message if it is off.
Christopher's Avatar
Iced Cap

Posts: 3,111
Location: Toronto, Ontario
I think you may be able to:

PHP Code:
ini_set('default_socket_timeout''60'
Where 60 is the number in seconds.
Christopher is offline
Reply With Quote
View Public Profile Visit Christopher's homepage!
 
Old 05-04-2006, 02:20 PM Re: Checking if server on or off. Help with stoping error message if it is off.
mad_willsy's Avatar
Super Spam Talker

Posts: 774
Name: Will Craig
Location: Cheltenham, Gloucestershire, UK
Nope. Any other way of checking file exsists/'opanable' from a remote server?
__________________
Wont :P
SoldierExteme.com - Free MMORPG - sign-up today!
Backthebulls.com - Free online games
mad_willsy is offline
Reply With Quote
View Public Profile Visit mad_willsy's homepage!
 
Old 05-04-2006, 02:28 PM Re: Checking if server on or off. Help with stoping error message if it is off.
Christopher's Avatar
Iced Cap

Posts: 3,111
Location: Toronto, Ontario
Try this: http://www.webhostingtalk.com/archiv.../394004-1.html
Christopher is offline
Reply With Quote
View Public Profile Visit Christopher's homepage!
 
Old 05-04-2006, 02:34 PM Re: Checking if server on or off. Help with stoping error message if it is off.
mad_willsy's Avatar
Super Spam Talker

Posts: 774
Name: Will Craig
Location: Cheltenham, Gloucestershire, UK
SOLVED

SOLUTIONL
PHP Code:
<?php $up = @fsockopen("86.128.132.191"80$errno$errstr1);  
if(
$up
{  
   
$off "NO";  

else 
{
   
$off "YES";

echo 
$off;
?>
If only I could give you more talkupation!!!
__________________
Wont :P
SoldierExteme.com - Free MMORPG - sign-up today!
Backthebulls.com - Free online games
mad_willsy is offline
Reply With Quote
View Public Profile Visit mad_willsy's homepage!
 
Old 05-05-2006, 06:24 AM Re: Checking if server on or off. Help with stoping error message if it is off.
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
seems your socket fails so you get a response

if your on php5 use

PHP Code:
 $off fasle;
 try{
  
$off  fsockopen("86.128.132.191"80$errno$errstr1); 
 }catch(
exception $e)
  
header('Location: /yourerror_handler/?error=$e');
 } 
Which should prevent the nasty failure page been disaply by wrapping your site round a nice error page that display the error $e.

Your on's and offs are a little confusing, use bool values for this IE true : false. Much easier to work with plus a bool = 1 byte while ON or OFF = 2 and 3 bytes respectively. So a successfull connection would set off to true.

Ibbo
__________________
www.nationalclubgolfer.com www.sportspub.co.uk www.bespokecc.co.uk www.centralmarquees.co.uk
Linux user #349545 :
(GNU/Linux)iD8DBQBAzWjX+MZAIjBWXGURAmflAKCntuBbuKCWenpm XoA7LNydllVQOwCf
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Old 05-05-2006, 06:33 PM Re: Checking if server on or off. Help with stoping error message if it is off.
mad_willsy's Avatar
Super Spam Talker

Posts: 774
Name: Will Craig
Location: Cheltenham, Gloucestershire, UK
Now thats bandwidth saving to the extreme!
__________________
Wont :P
SoldierExteme.com - Free MMORPG - sign-up today!
Backthebulls.com - Free online games
mad_willsy is offline
Reply With Quote
View Public Profile Visit mad_willsy's homepage!
 
Old 05-09-2006, 08:52 AM Re: Checking if server on or off. Help with stoping error message if it is off.
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
every byte counts
__________________
www.nationalclubgolfer.com www.sportspub.co.uk www.bespokecc.co.uk www.centralmarquees.co.uk
Linux user #349545 :
(GNU/Linux)iD8DBQBAzWjX+MZAIjBWXGURAmflAKCntuBbuKCWenpm XoA7LNydllVQOwCf
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Reply     « Reply to Checking if server on or off. Help with stoping error message if it is off.
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Webmaster Resources Marketplace:
Software Development Company | Webhosting.UK.com | Text Link Brokers 


   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15852 seconds with 12 queries