ed
Member
Registered: 10th Sep 03
User status: Offline
|
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
|
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
|
That looks like it will work, and seems like a sensible technique to use. Cheers
|
ed
Member
Registered: 10th Sep 03
User status: Offline
|
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]
|