sockets - Error in multicasting a message in java -
i need multicast message across connected clients facing problem. have tried following snippet 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 getting exception:
java.net.socketexception: not multicast address
i tried:
- localhost
- 127.0.0.1
- 192.168.1.29(my local ip)
what have gone wrong. being new topic unable debug it. help.
your code works me.
you don't need join group send it. receive it. if join it, need specify ip address valid multicast address. despite says in code posted, actual code doesn't use valid multicast address.
Comments
Post a Comment