Skip to content

net: ListenMulticastUDP setsockopt: not supported by windows #63529

Closed
@bt90

Description

@bt90

What version of Go are you using (go version)?

$ go version
go version go1.21.3 windows/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GOHOSTARCH=amd64
set GOHOSTOS=windows

What did you do?

package main

import (
	"fmt"
	"net"
)

func main() {
	multicastIP := net.ParseIP("ff02::c")
	multicastAddr := net.UDPAddr{IP: multicastIP}

	interfaces, err := net.Interfaces()
	if err != nil {
		fmt.Println("Failed to list interfaces", err)
		return
	}

	for _, iface := range interfaces {
		if iface.Flags&net.FlagUp == 0 || iface.Flags&net.FlagLoopback != 0 || iface.Flags&net.FlagMulticast == 0 {
			fmt.Println("Skipping interface", iface.Name)
			continue
		}

		conn, err := net.ListenMulticastUDP("udp6", &iface, &multicastAddr)
		if err != nil {
			fmt.Println("Failed to listen on", iface.Name, err)
			continue
		}

		fmt.Println("Listening on", iface.Name)

		defer conn.Close()
	}
}

What did you expect to see?

Example output on a Linux host:

Skipping interface lo
Listening on enp0s31f6
Listening on enxc4cbe10cec3d
Listening on wlp0s20f3
Listening on virbr0
Skipping interface wg0
Skipping interface wg1
Listening on docker0
Listening on br-651beae84a39
Listening on vethfed639d
Listening on vnet0

What did you see instead?

This fails for regular interfaces on Windows 10 and Windows 11 hosts:

Failed to listen on Ethernet-Instanz 0 listen udp6 [ff02::c]:0: setsockopt: not supported by windows
Skipping interface Loopback Pseudo-Interface 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixThe path to resolution is known, but the work has not been done.OS-Windows

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      close