Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Most multicast servers are indiscriminate about who they
will talk to. Therefore, it’s easy to join a group and watch the data
that’s being sent to it. Example
14-1 is a MulticastSniffer
class that reads the name of a multicast group from the
command line, constructs an InetAddress from that hostname, and creates a
MulticastSocket, which attempts to
join the multicast group at that hostname. If the attempt succeeds,
MulticastSniffer receives datagrams
from the socket and prints their contents on System.out. This program is useful primarily
to verify that you are receiving multicast data at a particular host.
Most multicast data is binary and won’t be intelligible when printed as
ASCII.