UDP Multicast HELP!

Larry ld at nospam.com
Wed Jul 24 18:03:27 EDT 2002


I've spent 2 hours searching google for my answer and I can't find it...you
are my last hope!

How do I set up a socket to join and receive on a UDP multicast?
I have tried the following on a windows 2000 machine...
====================================

import socket

s1 = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
s1.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, '234.5.6.7')
s1.bind(('',6000))

while 1:
    data = s1.recv(10000)
    print data

====================================

It just HANGS at the s1.recv(10000).  However, if I don't try to do a
multicast and just have server UDP to the regular IP, I receive the packets
just fine.

Now, when I take the above code to a Linux computer, I can't even run the
program cuz I get and error that says...

"Invalid argument" when it gets to line
s1.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, '234.5.6.7')

I really need to be able to receive multicast messages.  Your help is most
appreciated!!!

Larry







More information about the Python-list mailing list