If your software is just waiting for data from the home automation device, the only way to detect that the device is gone is to enable the SO_KEEPALIVE parameter in the slot, which is open for communication with the device.
To do this, simply call the setKeepAlive (true) method on the socket, and this will cause the main socket implementation to include the SO_KEEP_ALIVE parameter.
This will cause the base implementation to periodically exchange some data with the remote endpoint, and if the device dies while waiting for data, an exception will be thrown.
The only problem is that maintaining the latency depends on the operating system and sometimes cannot be changed.
If you need shorter timeouts, there is no other way than to implement a periodic probe on the device.
Reginaldo
source share