[java] Multicast Channels
It it possible to have a DatagramChannel send and receive multicast messages? I tried this
group = new InetSocketAddress(InetAddress.getByName("228.5.6.7"),5000);
channel = DatagramChannel.open();
channel.configureBlocking(false);
channel.socket().setReuseAddress(true);
channel.socket().setBroadcast(true);
channel.socket().bind(group);
channel.register(selector, SelectionKey.OP_READ);
The bind get and exception
"java.net.BindException: Cannot assign requested address: bind"
I understand the error I''m just not setting up the socket correctly.
Since the channel.socket() only returns a DatagramSocket and not MulticastSocket I''m thinking you can''t except why is there a setBroadcast() method? I''ve been searching the net for the past hour with no luck.
All of my existing network code uses Channels and I would like to avoid just using a non-channeled MulticastSocket if possible.
Any ideas?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement