title: Golang UDP Multicast
body: <p>Im doing some testing for receiving multicast UDP stream and save it to file using the below functions:</p>
  
  <pre><code>func Record2(udp string, filePath string) {
      c1, err := net.ListenPacket("udp4", udp)
      if err != nil {
          return
      }
      defer c1.Close()
      p1 := ipv4.NewPacketConn(c1)
      en0, err := net.InterfaceByName("enp3s0")
      addr, _ := net.ResolveUDPAddr("udp4", udp)
      if err := p1.JoinGroup(en0, addr); err != nil {
  
      }
      Bee.DelFile(filePath)
      fo, err := os.Create(filePath)
      defer fo.Close()
      if err != nil {
          panic(err)
      }
      io.Copy(fo, p1)
  
  }
  func Record(udp string, filePath string) {
      addr, err := net.ResolveUDPAddr("udp4", udp)
  
      if err != nil {
          return
      }
      Bee.DelFile(filePath)
      fo, err := os.Create(filePath)
      defer fo.Close()
      if err != nil {
          panic(err)
      }
      l, err := net.ListenMulticastUDP("udp4", nil, addr)
  
      defer l.Close()
      l.SetReadBuffer(maxDatagramSize)
      io.Copy(fo, l)
  
  }
   go Record2("224.1.2.2:1234", "file1")
   go Record2("224.1.2.1:1234", "file2")
   go Record("224.1.2.2:1234", "file3")
   Record("224.1.2.1:1234", "file4")
  </code></pre>
  
  <p>the problem is that udp stream have different content while all files saved got the same content of the first address</p>
  
  <p>this is not occuring when using UDP addresses with different ports</p>
  
  <p>im not sure if this is related to SO_REUSEADDR</p>
  
  <p>how to fix that?</p>