UDP Multicast HELP!

Martin v. Loewis martin at v.loewis.de
Thu Jul 25 04:09:02 EDT 2002


"Larry" <ld @ nospam.com> writes:

> 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.

But it is a fact. Python just exposes the socket API of the underlying
operating system. Please take a moment to read the Linux setsockopt(2)
man page. You notice that setsockopt takes a pointer and a length.

Python currently does not "know" what all those socket options
mean. It just exposes the bare setsockopt API to you. Now,
IP_ADD_MEMBERSHIP requires a C structure, so you have to give it a C
structure. For that, you need to understand what data to put into the
C structure, *and* you have to understand how the C compiler lays out
this structure in memory. Then you can construct a Python string that
has the same layout.

Sorry this is so complicated; if you feel it should be simplified in a
future version, feel free to propose specific patches, or write a PEP.

Regards,
Martin



More information about the Python-list mailing list