How to specify SEND interface for multicast in Python?

There are many examples for receiving multicast messages using a network interface (NIC, for example eth0, 127.0.0.1, etc.). However, a few discussions / examples on how to send multicast (UDP) messages to a specific interface, such as a local loop (127.0.0.1) instead of eth0 by default.

Reference: RedHat Linux, Python, 224.1.1.1 5005

Python Code Example in Python Multicast

Similar discussion for IPv6 How to send multicast packets through a dedicated interface in Linux

A similar discussion for Windows How to multicast (send) to the first network adapter?

Thanks in advance.

+4
source share
1 answer

The question is what did you bundle How to multicast (send) to the first network adapter? mentions that you can use IP_MULTICAST_IF :

 sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton(addr)) 
+4
source

Source: https://habr.com/ru/post/1401362/


All Articles