I’ve been looking around to find a way to have SocketServer python module to listen on multicast without success.
Anyone managed to do so ?
Any insight will be greatly appreciated !
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The docs (http://docs.python.org/library/socketserver.html) don’t make any mention about multicast, and the source code (http://hg.python.org/cpython/file/2.7/Lib/SocketServer.py) doesn’t set any socket options you’d expect to see in a multicast listener (e.g. socket.IP_ADD_MEMBERSHIP), so I’d say SocketServer doesn’t support multicast.
I assume (you should try to include a code snippet with the error you’re getting) you’re trying to make a UDPServer and you’re getting an error that is something like:
This is because UDPServer is a subclass of TCPServer, and when a TCPServer is created it calls bind() on the specified address. You’re not supposed to bind to a multicast address for listening though (hence the error), you use the IP_ADD_MEMBERSHIP socket option to listen for multicast traffic.
Looks like you may have to roll your own multicast server.