title: Send and receive IPv6 link-local multicast UDP datagrams in Python?
body: <p>This following is a straightforward IPv4 UDP broadcast, followed by listening on all interfaces.</p>
  
  <pre><code>sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, True)
  sock.bind(("", 1337))
  sock.sendto("hello world", ("255.255.255.255", 1337))
  while True:
      data, addr = sock.recvfrom(0x100)
      print "received from {0}: {1!r}".format(addr, data)
  </code></pre>
  
  <p>I want to adjust this to send and receive both IPv4 and IPv6.</p>
  
  <p>I've poked around and read as much as I can and believe the following is roughly the route I need to take:</p>
  
  <ol>
  <li>Create an IPv6 socket.</li>
  <li>Add the socket to a link or site local multicast group.</li>
  <li>Send the UDP packets to the multicast address for the group in use.</li>
  </ol>
  
  <p>Further info I have is that I may need to bind to several interfaces, and tell the socket using <code>setsockopt()</code> that it should also receive multicast packets. Lastly <code>getaddrinfo()</code> can be used across the board to gracefully "drop back" to IPv4 where IPv6 isn't available.</p>
  
  <p>I have much of this implemented, but stumble primarily on the multicasting parts. A complete code example in Python, or vivid description of the constants and addresses needed are preferred.</p>