O'Reilly logo

Learning Network Programming with Java by Richard M Reese

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

UDP multicasting with channels

We can also multicast with channels. We will use IPv6 to demonstrate this process. The process is similar to our previous use of the DatagramChannel class, except that we need to use a multicast group. To do this, we need to know which network interfaces are available. Before we get into the specifics of using channels to multicast, we will demonstrate how to obtain a list of network interfaces for a machine.

The NetworkInterface class represents a network interface. This class was discussed in Chapter 2, Network Addressing. The following is a variation of the approach demonstrated in that chapter. It has been augmented to show whether a specific interface supports multicasting, as shown next:

 try { Enumeration<NetworkInterface> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required