UDP Multicast HELP!

Larry ld at nospam.com
Wed Jul 24 23:34:16 EDT 2002


"Martin v. Loewis" <martin at v.loewis.de> wrote in message
news:m38z40hi1o.fsf at mira.informatik.hu-berlin.de...

> The problem here is that IP_ADD_MEMBERSHIP requires a struct ip_mreq,
> which is typically defined as
>
> struct ip_mreq
>   {
>     struct in_addr imr_multiaddr;       /* IP multicast address of group
*/
>     struct in_addr imr_interface;       /* local IP address of interface
*/
>   };
>
> So this is an 8-byte value. For imr_interface, you usually specify
> INADDR_ANY, which is '\0\0\0\0', so you really need to use
>
> group = socket.inet_aton('234.5.6.7') + '\0\0\0\0'
> s1.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, group)
>
> [Strictly speaking, you should use struct.pack to build the struct,
>  but the code above is just as portable, I assume]

I truly appreciate you taking time to respond, but I really don't understand
what you are trying to explain to me.  Everything else in python seems so
easy, and creating a tcp socket and udp socket is so easy, just a few lines
of code.  I am really surprised that there is no EASY way to join a group.

Now, your explanation SEEMS like all I need to do is make a few adjustments,
but the "struct" throws a loop at me cuz I never messed with that before.
If I really do just need an "adjustment" to the above code I posted, could
you repost my code with the corrections so I can see how it all comes
together!

Thanks,
Larry





More information about the Python-list mailing list