Charles-Francois Natali <[email protected]> added the comment:
I tested it on a Windows XP box, and encountered the same problem.
The error is raised because Windows XP requires the socket to be bound before
calling setsockopt(IPPROTO_IP, IP_ADD_MEMBERSHIP, mreq).
So calling bind() before setsockopt() solves this error.
But then you also need to specify for the sender the interface to use using
setsockopt(IPPROTO_IP, IP_MULTICAST_IF, address)
Here's a working example:
---- sender ----
from socket import *
s = socket(AF_INET, SOCK_DGRAM)
s.setsockopt(IPPROTO_IP, IP_MULTICAST_IF, inet_aton('127.0.0.1'))
s.sendto(b'foo', ('224.0.0.1', 4242))
----------------
--- receiver ---
from socket import *
s = socket(AF_INET, SOCK_DGRAM)
s.bind(('127.0.0.1', 4242))
mreq = inet_aton('224.0.0.1') + inet_aton('127.0.0.1')
s.setsockopt(IPPROTO_IP, IP_ADD_MEMBERSHIP, mreq)
s.recv(100)
----------------
So it's not a Python bug.
Since multicast is tricky, it might be a good idea to add a short example
somewhere in the documentation though.
----------
nosy: +neologix
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue1462440>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com