Repository navigation
Missing support for Source Specific Multicast #89415
Description
Activity
It appears that Python's socket module is missing support for the IGMPv3 socket options needed to support Source Specific Multicast. Many developers appear to be adding the necessary constants through something like:
if not hasattr(socket, "IP_UNBLOCK_SOURCE"): setattr(socket, "IP_UNBLOCK_SOURCE", 37) if not hasattr(socket, "IP_BLOCK_SOURCE"): setattr(socket, "IP_BLOCK_SOURCE", 38) if not hasattr(socket, "IP_ADD_SOURCE_MEMBERSHIP"): setattr(socket, "IP_ADD_SOURCE_MEMBERSHIP", 39) if not hasattr(socket, "IP_DROP_SOURCE_MEMBERSHIP"): setattr(socket, "IP_DROP_SOURCE_MEMBERSHIP", 40)
...but it would be nice if these were added to the official module as they are supported under current versions of Windows, Linux, and BSD at the least.
- added3.7 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of life3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
on Sep 21, 2021 19 remaining items
That is what I figured it needs to match the constant flags on the OS. For darwin it says 70. So mac needs something different ?
I found a header for win 10 SDK. It says 15.
https://github.com/tpn/winsdk-10/blob/master/Include/10.0.16299.0/shared/ws2ipdef.h
I'm sorry to ask if getting the right flags setup. Is socket.IPPROTO_IP the correct way to setup SSM because the old examples out there using socket.SOL_IP cause endless "invalid argument" errors. The struct packing is similar to the windows docs. Needs to join the group, source ip, then local ip
Here is a patch for windows and macOS I've come up with. Will eventually test on macOS but Windows first.
platform = platform.system() if (platform == "Windows"): if not hasattr(socket, "IP_UNBLOCK_SOURCE"): setattr(socket, "IP_UNBLOCK_SOURCE", 18) if not hasattr(socket, "IP_BLOCK_SOURCE"): setattr(socket, "IP_BLOCK_SOURCE", 17) if not hasattr(socket, "IP_ADD_SOURCE_MEMBERSHIP"): setattr(socket, "IP_ADD_SOURCE_MEMBERSHIP", 15) if not hasattr(socket, "IP_DROP_SOURCE_MEMBERSHIP"): setattr(socket, "IP_DROP_SOURCE_MEMBERSHIP", 16) elif (platform == 'Darwin'): if not hasattr(socket, "IP_UNBLOCK_SOURCE"): setattr(socket, "IP_UNBLOCK_SOURCE", 73) if not hasattr(socket, "IP_BLOCK_SOURCE"): setattr(socket, "IP_BLOCK_SOURCE", 72) if not hasattr(socket, "IP_ADD_SOURCE_MEMBERSHIP"): setattr(socket, "IP_ADD_SOURCE_MEMBERSHIP", 70) if not hasattr(socket, "IP_DROP_SOURCE_MEMBERSHIP"): setattr(socket, "IP_DROP_SOURCE_MEMBERSHIP", 71) else: if not hasattr(socket, "IP_UNBLOCK_SOURCE"): setattr(socket, "IP_UNBLOCK_SOURCE", 37) if not hasattr(socket, "IP_BLOCK_SOURCE"): setattr(socket, "IP_BLOCK_SOURCE", 38) if not hasattr(socket, "IP_ADD_SOURCE_MEMBERSHIP"): setattr(socket, "IP_ADD_SOURCE_MEMBERSHIP", 39) if not hasattr(socket, "IP_DROP_SOURCE_MEMBERSHIP"): setattr(socket, "IP_DROP_SOURCE_MEMBERSHIP", 40)- added a commit that references this issue
on Apr 22, 2023 - added a commit that references this issue
on Apr 27, 2023 - added a commit that references this issue
on Jun 3, 2023 - added a commit that references this issue
on Jun 3, 2023
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
IP_*constants insocketmodule in the docs #105266IP_*constants insocketmodule in the docs (GH-105266) #105270