简体   繁体   中英

How to specify the multicast SEND interface in Python?

There is quite a few examples to RECEIVE multicast messages with a spcific network interface (NIC, eg eth0, 127.0.0.1 etc). However, there is few discussion/examples about how to SEND multicast (UDP) messages to a specific interface, eg local loop (127.0.0.1) instead of eth0 by default.

Background: RedHat Linux, Python, 224.1.1.1 5005

Python Code example in Multicast in Python

A similar discuss for IPv6 How to send multicast packets via a specfic interface in Linux

A similar discuss for Windows How to Multicast (send) to first NIC?

Thanks in advance.

The question that you've linked How to Multicast (send) to first NIC? mentions that you could use IP_MULTICAST_IF :

sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton(addr))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM