Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No results (Windows) #80

Open
jmarkel44 opened this issue Mar 31, 2020 · 2 comments
Open

No results (Windows) #80

jmarkel44 opened this issue Mar 31, 2020 · 2 comments

Comments

@jmarkel44
Copy link

Seems to work fine on a Pi. Here's the same code running under Windows:

c:\repo\src>go run mdns.go
2020/03/31 16:21:23 [ERR] mdns: Failed to bind to udp6 port: listen udp6 [ff02::fb]:5353: setsockopt: not supported by windows
2020/03/31 16:21:24 [ERR] mdns: Failed to read packet: read udp4 0.0.0.0:52447: use of closed network connection

@jmarkel44
Copy link
Author

With some debug info enabled and Wireshark running, it looks like the query packet is never sent:

c:\repo\src>go run mdns.go
searching for new entries
[DEBUG] starting the query
2020/04/01 07:19:41 [ERR] mdns: Failed to bind to udp6 port: listen udp6 [ff02::fb]:5353: setsockopt: not supported by windows
[DEBUG] service -> _workstation._tcp.local.
[DEBUG] Sending the question
[DEBUG] Sending the query <-- would've expected to see something in Wireshark here (mdns filtered)
[DEBUG] Write to ipv4 OK
[DEBUG] write to ipv6 OK
[DEBUG] params.Timeout = 1000000000
[DEBUG] time elapsed
[DEBUG] finished
2020/04/01 07:19:43 [INFO] mdns: Closing client {0xc000080020 0xc000080028 0xc000080030 <nil> 1 0xc00004a180}

@clowenhg
Copy link

It seems that on Windows we need to explicitly set params.Interface

Here's a quick snippet of code that makes my queries work on Windows.
Note: my LAN network adapter is "Ethernet 7"

I'm not sure the best way to find the right interface without knowing the name ahead of time yet.

	ifaces, _ := net.Interfaces()
	var iface net.Interface
	for _, i := range ifaces {
		fmt.Println(i.Name)
		if strings.Contains(i.Name, "Ethernet 7") {
			iface = i
			addrs, _ := i.Addrs()
			for _, a := range addrs {
				fmt.Println(a)
			}
		}
	}
	entries := make(chan *mdns.ServiceEntry, 1)
	defer close(entries)

	params := mdns.DefaultParams("_cal._tcp")
	params.Timeout = 2 * time.Second
	params.Entries = entries
	params.DisableIPv6 = true
	params.Interface = &iface

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants