It would be so great if we could simply test a device’s online/offline status. But we can’t. And the first real issue is determining exactly what online/offline means. So have a look at this (soon-to-be) 3-part series on the subject. Thoroughly written.