python / cpython

The Python programming language
https://www.python.org
Other
62.3k stars 29.93k forks source link

recvmsg support on Windows #80398

Open a5ad8fb9-cdef-4530-9287-4bb63eba5fb9 opened 5 years ago

a5ad8fb9-cdef-4530-9287-4bb63eba5fb9 commented 5 years ago
BPO 36217
Nosy @pfmoore, @tjguk, @chrysn, @zware, @zooba

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: ```python assignee = None closed_at = None created_at = labels = ['type-feature', 'OS-windows'] title = 'recvmsg support on Windows' updated_at = user = 'https://github.com/chrysn' ``` bugs.python.org fields: ```python activity = actor = 'chrysn' assignee = 'none' closed = False closed_date = None closer = None components = ['Windows'] creation = creator = 'chrysn' dependencies = [] files = [] hgrepos = [] issue_num = 36217 keywords = [] message_count = 1.0 messages = ['337337'] nosy_count = 5.0 nosy_names = ['paul.moore', 'tim.golden', 'chrysn', 'zach.ware', 'steve.dower'] pr_nums = [] priority = 'normal' resolution = None stage = None status = 'open' superseder = None type = 'enhancement' url = 'https://bugs.python.org/issue36217' versions = [] ```

a5ad8fb9-cdef-4530-9287-4bb63eba5fb9 commented 5 years ago

Windows has support for advanced socket APIs of RFC 3542 (eg. pktinfo, see https://docs.microsoft.com/en-us/windows/desktop/api/ws2ipdef/ns-ws2ipdef-in6_pktinfo), but those can not be used on Python as there is no recvmsg implementation (tested on 3.7.1 on Windows 10).

The recvmsg function is, among other things, required for implementing the CoAP protocol (RFC 7252: introspection of ICMP errors).

Windows does have a recvmsg function (as documented at https://msdn.microsoft.com/en-us/a46449f7-3206-45e9-9df0-f272b8cdcc4b), and supports flags to make actual use of it (like RECVPKTINFO above). Given many of the missing flags of RFC 3542 are being added in bpo-29515, please consider adding a recvmsg method to Windows socket objects.

KhazAkar commented 1 year ago

Here is MS docs about sendmsg/recvmsg WSASendMsg: https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasendmsg For WSARecvMsg, it's needed to implement it yourself by using this doc (callback for LPFN_WSARECVMSG): https://learn.microsoft.com/en-us/windows/win32/api/mswsock/nc-mswsock-lpfn_wsarecvmsg

James-E-A commented 3 weeks ago

Pending this being implemented, is there any way to tell on Python on Windows whether a received UDP packet was multicast or unicast?
https://stackoverflow.com/a/75621192/1874170

Or, if not, is there any other way to filter incoming packets on that basis, so that only multicast packets are received in the first place?