jgphp Posted January 5, 2012 Share Posted January 5, 2012 Hello All happy new year I am trying to make a php page that detects if something is plugged in to the ethernet port. This would be complex if not impossible. I however managed to do something similar the device that will be plugged in has a static address 192.168.1.1. so I created a ping that says if the device is up or down. function ping($host, $port, $timeout) { $fP = fSockOpen($host, $port, $errno, $errstr, $timeout); $status; if ($fP) { echo "Device is ready to accept data";} else { echo "Device Down - Retrying connection"; } } What I would like to do is have a script that is constantly checking is the device is plugged or when it is not (so sort of a loop or auto detect). The idea is to have an image with the device up or down. Regards and a happy new year JG Quote Link to comment https://forums.phpfreaks.com/topic/254448-php-ping-test/ Share on other sites More sharing options...
scootstah Posted January 6, 2012 Share Posted January 6, 2012 I would use an AJAX request that refreshes every 5 - 10 seconds or so and calls your script. Quote Link to comment https://forums.phpfreaks.com/topic/254448-php-ping-test/#findComment-1304664 Share on other sites More sharing options...
jgphp Posted January 6, 2012 Author Share Posted January 6, 2012 would you refresh the actual page or is it not better for the system to stay in a loop until the device is plugged in. Quote Link to comment https://forums.phpfreaks.com/topic/254448-php-ping-test/#findComment-1304749 Share on other sites More sharing options...
scootstah Posted January 6, 2012 Share Posted January 6, 2012 No, just refresh the AJAX call. Quote Link to comment https://forums.phpfreaks.com/topic/254448-php-ping-test/#findComment-1304751 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.