Almighty Bus Error

Loading search...

Multicast: An UDP strong point

Multicast is a way to distribute UDP messages to multiple hosts in an automated fashion. It works by making every host join a group which is composed of an IP address in the range 224.0.0.0 to 239.255.255.255 and a port. Every message sent to a group will be delivered to every host that has joined it.
Since it can generate alot of traffic, multicast is only used at a LAN or intranet level.

In Java, to use Multicast there is an object named MulticastSocket. It has mostly the same usage as the DatagramSocket but has an joinGroup method and makes the process join a multicast group:

MulticastSocket mso = new MulticastSocket( 9001 );
mso.joinGroup( InetAddress.getByName("224.0.5.8") );

For more information about receiving and sending messages in UDP go here.