I have an Android service that listens and responds to packets received via multicast.
This works most of the time, but unfortunately I find that from time to time it just stops receiving packets. The thread remains blocked when MulticastSocket.receive () is called, but nothing comes out. I slowly tried to track what causes this, and I found that turning the wireless network on and off, or changing the wireless connection, would do it.
To successfully continue listening to my packages, I need to close MulticastSocket and recreate it again. However, I did not find any way to do this. I do not receive a notification that something has happened: no intentions, no Java exceptions, nothing. I would expect the receiver to receive an IOException if the socket became invalid, but this does not seem to be happening.
Can someone give an idea of ββwhat is really happening and (b) how to get around it? Right now, my best guess is to constantly destroy and recreate a socket every ten seconds or so, and that is just evil.
source
share