Search This Blog

Showing posts with label multicasting. Show all posts
Showing posts with label multicasting. Show all posts

Java Program to Implement Broadcasting System Between a Server and Many Clients

Multicast and Broadcast using java program. java source code sample program for broadcasting or multicasting
Screenshot of broadcast server and clients using java
In this post we will see a java program which implements a broadcasting system. A Server can send a message as a multicast message into a multicast group. Any client can receive the multicasted packets after joining the group. The program make use of MulticastSocket class which is a subclass (derived class) of DatagramSocket class. Multicasting is almost same as UDP messaging. Datagram packets are used by MulticastSocket class. MulticastSocket class has two methods joinGroup() and leaveGroup(), each receive a InetAddress object as parameter which should be representing a multicast IP address. The datagrams sent using the MulticastSocket object should be addressed to a multicast group with IP between 224.0.0.0 and 239.255.255.255. These are IP addresses reserved for multicasting. The following java program to implement broadcasting using Multicast will tell you more.