Search code examples
socketsudpwifi

DatagramSocket notify remote device connected or not?


I am working on project to send sensor data from Android device to PC server. I created 2 connection methods Bluetooth and wifi . I would like to notify system whether android device connected through DatagramSocket and cancel wifi connection. Is there any method to check it is connected or not. I think isConnected() method is not for incoming connections. Any suggestions please


Solution

  • UDP does not have any connections, not even virtual ones, so there can be no notification of connection loss.

    You will have to resort to application-level timeouts and/or polling.