You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following program creates a unicast UDP4 socket for sending, a multicast UDP4 socket for receiving, and sends one packet of data from the former to the latter. It should succeed (and does on Linux), but on Windows (Windows 7, 64-bit, go v1.4.2), it hangs on the ReadFrom() call.
Note: If you go to udpsock_posix.go in the std library, and in listenIPv4MulticastUDP(), change:
if err := setIPv4MulticastLoopback(c.fd, false); ...
to:
if err := setIPv4MulticastLoopback(c.fd, true); ...
the program works as expected, so it seems like the loopback flag should be set on Windows (maybe in setDefaultMulticastSockopts), or at least the loopback flag should be exposed through the API.
package main
import "net"
func main() {
src, err := net.Dial("udp4", "238.98.76.54:4378")
if err != nil {
panic("test failed")
}
defer src.Close()
addr := net.ParseIP("238.98.76.54")
dest, err := net.ListenMulticastUDP("udp4", nil, &net.UDPAddr{IP: addr, Port: 4378})
if err != nil {
panic("test failed")
}
defer dest.Close()
if _, err := src.Write(make([]byte, 100)); err != nil {
panic("test failed")
}
b := make([]byte, 1024)
n, _, err := dest.ReadFrom(b)
if err != nil || n != 100 {
panic("test failed")
}
}
The text was updated successfully, but these errors were encountered:
mikioh
changed the title
Loopback flag not set on IP4 multicast socket on Windows
net: ListenMulticastUDP does't set {IP,IPV6}_MULTICAST_LOOP
May 7, 2015
Because ListenMulticastUDP is just for convenience of simple small applications. There are a few packages for general purpose uses, golang.org/x/net/ipv4 and golang.org/x/net/ipv6.
mikioh
changed the title
net: ListenMulticastUDP does't set {IP,IPV6}_MULTICAST_LOOP
net: ListenMulticastUDP doesn't set {IP,IPV6}_MULTICAST_LOOP
May 7, 2015
The following program creates a unicast UDP4 socket for sending, a multicast UDP4 socket for receiving, and sends one packet of data from the former to the latter. It should succeed (and does on Linux), but on Windows (Windows 7, 64-bit, go v1.4.2), it hangs on the ReadFrom() call.
Note: If you go to udpsock_posix.go in the std library, and in listenIPv4MulticastUDP(), change:
if err := setIPv4MulticastLoopback(c.fd, false); ...
to:
if err := setIPv4MulticastLoopback(c.fd, true); ...
the program works as expected, so it seems like the loopback flag should be set on Windows (maybe in setDefaultMulticastSockopts), or at least the loopback flag should be exposed through the API.
The text was updated successfully, but these errors were encountered: