corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » PHP Connection Status


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author PHP Connection Status
ed
Member

Registered: 10th Sep 03
User status: Offline
23rd Oct 09 at 15:24   View User's Profile U2U Member Reply With Quote

I've had a little look into doing this before but I don't really know that it is I'm looking for. Basically I have a page which displays two webcam feeds:

http://www.windmill-farm.co.uk/46-webcams.html

However one of them seems to be faulty and intermittently stops working for some reason. Is there a function in PHP that would let me test the connection beforehand returning the status (e.g. 200 if it's working)? I know there ought to be, I just don't know what it'd be called
Dom
Member

Registered: 13th Sep 03
User status: Offline
23rd Oct 09 at 17:46   View User's Profile U2U Member Reply With Quote

The one that fails, are you able to logon to admin pages (etc) when it's gone down?

You could simply check to see if you can get a page from the webcam (using fopen or fsocketopen) and then use stream_set_timeout to trigger a timeout that you can then use to mark the camera as being offline...

edit - http://www.webmasterworld.com/php/3154615.htm

[Edited on 23-10-2009 by Dom]
ed
Member

Registered: 10th Sep 03
User status: Offline
23rd Oct 09 at 19:51   View User's Profile U2U Member Reply With Quote

That looks like it will work, and seems like a sensible technique to use. Cheers
ed
Member

Registered: 10th Sep 03
User status: Offline
23rd Oct 09 at 22:46   View User's Profile U2U Member Reply With Quote

For reference, I did this:

code:
$timeout=3;
$old=ini_set('default_socket_timeout', $timeout);
$file=@fopen('http://wf.dnsdojo.org:1180/jpg/image.jpg', 'r')
or $fail=true;
ini_set('default_socket_timeout', $old);


Seems to do the trick

[Edited on 23-10-2009 by ed]

 
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
Help from those who know about computer- broadband problem Dr Pepper Geek Day 9 528
2nd Feb 04 at 20:43
by Simon
 
Computer Help! jamied General Chat 5 148
12th Aug 05 at 12:54
by 306CORSA
 
PHP FTP help ASAP please :) Antz Geek Day 1 159
8th Jan 07 at 18:12
by andy.ros
 
PS3 - Is it wifi? Or do you have to use the cable provided to get on the net? Matt H Geek Day 32 848
28th Mar 07 at 08:09
by Dom
 
COD5 Tips/Tricks VegasPhil Geek Day 77 3210
6th Jan 09 at 14:28
by DannyB
 

Corsa Sport » Message Board » Off Day » Geek Day » PHP Connection Status 29 database queries in 0.0081141 seconds