title: socket.SO_REUSEADDR: packets received by every vs by newest listener
body: <p>I got multiple processes listening on the same port subscribed to a multicast address. Packets to this address reach every process. However, when I contact them via unicast, only the newest process gets the message. Where is this behavior documented? How can I change it?</p>
  
  <p>Demo program (Python):</p>
  
  <pre><code>import socket,os,struct,sys
  
  def server():
      sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
      sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
      sock.bind(('', 4242))
  
      mreq = '\xef\x01\x02\x03' + struct.pack('=I', socket.INADDR_ANY)
      sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
  
      while True:
          d = sock.recvfrom(1024)
          print('[s' + str(os.getpid()) + '] ' + repr(d))
  
  def client():
      caddr = '239.1.2.3'
      caddr = '127.0.0.1' # Uncomment this and all servers print
      csock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
      csock.sendto('data from ' + str(os.getpid()), 0, (caddr, 4242))
  
  def main():
      if sys.argv[1] == 's':
          server()
      else:
          client()
  
  if __name__ == '__main__':
      main()
  </code></pre>