I get a SocketException when trying to call joinGroup(addr) on MulticastSocket. This is only happening on a Windows machine that we have setup to auto start our appliction when the machine is booted up.
It seems like the exception is thrown because Windows has not completely finished its startup process and here is the exception.
java.net.SocketException: error setting options
at java.net.PlainDatagramSocketImpl.join(Native Method)
at java.net.PlainDatagramSocketImpl.join(Unknown Source)
at java.net.MulticastSocket.joinGroup(Unknown Source)
On startup of our app, if we wait a minute before trying to join the group, everything works fine.
So we decided to put in a retry loop so that it will connect as soon as the network is available which seemed to work. After two failures, the third attempt to join the group works.
The problem is, now the MulticastSocket does not receive any messages from the group, even though it joined up fine.
I am creating a new MulticastSocket after each failure and discarding the old one.
Why would a failure to join the group on one MulticastSocket affect the one that joined without any errors, and how could I possibly work around this?