Note that there are some explanatory texts on larger screens.

plurals
  1. POpython odd multicast socket exception
    primarykey
    data
    text
    <p>I have some example python code that I got from another stack overflow answer (can't remember where), that implements multicasting. The following code should set up a socket object for receiving multicast packets. I encapsulated it in a class like so:</p> <p><code> class Multisock:</p> <pre><code>def __init__(self, MCAST_GRP, MCAST_PORT, packsize): import socket import struct self.MCAST_GRP = MCAST_GRP self.MCAST_PORT = MCAST_PORT self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.sock.bind(('', MCAST_PORT)) mreq = struct.pack("4sl", socket.inet_aton(MCAST_GRP), socket.INADDR_ANY) self.sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq) </code></pre> <p></code></p> <p>However, this gives me this error:</p> <p><code></p> <pre><code>Traceback (most recent call last): File "./Audiorecv.py", line 41, in &lt;module&gt; sock = MulticastNetworking.Multisock('244.1.1.1', 5007, chunk) File "/home/wheybags/Multicast-Voice-Chat/MulticastNetworking.py", line 30, in __init__ self.sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq) File "/usr/lib/python2.7/socket.py", line 224, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 22] Invalid argument </code></pre> <p></code></p> <p>Which is really confusing because if I just set MCAST_GRP statically to a string representing an ip, it works, but it gives the error above if I try to use a constructor argument.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload