Does Java NIO support broadcast or multicast?

两盒软妹~` 提交于 2019-12-06 00:40:44

NIO2 supports multicast, that's in Java 7.

http://javanio.info/filearea/nioserver/WhatsNewNIO2.pdf

Before NIO2 you have to make use of all kinds of hacks to make a datagram channel join a multicast group. Not sure how they could have left multicast channels out of NIO1.

You don't need to use NIO for this, java.net.MulticastSocket supports this directly.

But, to completely answer your question, no. You cannot use a DatagramChannel because you cannot tell it what socket to use, and there is nothing else even close to what you would need in NIO.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!