简体   繁体   English

如何在Python中指定多播SEND接口?

[英]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). 有很多使用特定网络接口(NIC,例如eth0、127.0.0.1等)来接收多播消息的示例。 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. 但是,关于如何将多播(UDP)消息发送到特定接口的讨论/示例很少,例如默认情况下是本地循环(127.0.0.1)而不是eth0。

Background: RedHat Linux, Python, 224.1.1.1 5005 背景:RedHat Linux,Python,224.1.1.1 5005

Python Code example in Multicast in Python Python 组播中的Python代码示例

A similar discuss for IPv6 How to send multicast packets via a specfic interface in Linux 关于IPv6的类似讨论如何在Linux中通过特定接口发送多播数据包

A similar discuss for Windows How to Multicast (send) to first NIC? Windows的类似讨论如何向第一个NIC组播(发送)?

Thanks in advance. 提前致谢。

The question that you've linked How to Multicast (send) to first NIC? 您已将“ 如何组播(发送)”链接到第一个NIC的问题? mentions that you could use IP_MULTICAST_IF : 提到您可以使用IP_MULTICAST_IF

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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