I need to multicast a message across connected clients but facing a problem. I have tried the following snippet for this link:
String msg = "Hello";
InetAddress group = InetAddress.getByName("228.5.6.7");
MulticastSocket s = new MulticastSocket(6789);
s.joinGroup(group);
DatagramPacket hi = new DatagramPacket(msg.getBytes(), msg.length(),
group, 6789);
s.send(hi);
I am getting an exception:
java.net.SocketException: Not a multicast address
I tried:
- localhost
- 127.0.0.1
- 192.168.1.29(my local ip)
What could have gone wrong. Being new to this topic i am unable to debug it. Thanks for any help.