Multicasting on the loopback device

 ̄綄美尐妖づ 提交于 2019-12-03 06:14:10

You can use multicast on loopback but you have to add a new route because your OS using default external interface by default for multicast. Also multicast can be disabled by default on loopback. On linux you can change this with this command :

route add -net 224.0.0.0 netmask 240.0.0.0 dev lo
ifconfig lo multicast

I wish to send UDP multicast packets to loopback address

Stop right there. You can't do that. It's impossible. You can only send multicasts to multicast addresses. Your code doesn't do any multicasting, just sending to 127.0.0.1.

If you're only sending to the localhost, why are you using multicast at all? Do you have multiple listening processes?

the src ip is taken from my default network interface(i.e interface which is my default gateway)

Very likely, as you haven't bound your socket. What did you expect?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!