Open zuozhehao opened 2 years ago
I'm still confused on why s.ifaceIPs
is nil only on Windows? Doesn't make any sense!
I'm still confused on why
s.ifaceIPs
is nil only on Windows? Doesn't make any sense!
I haven't added any code yet, just use the example code
package main
import (
"github.com/brutella/hap"
"github.com/brutella/hap/accessory"
"context"
"log"
"os"
"os/signal"
"syscall"
)
func main() {
// Create the switch accessory.
a := accessory.NewSwitch(accessory.Info{
Name: "Lamp",
})
// Store the data in the "./db" directory.
fs := hap.NewFsStore("./db")
// Create the hap server.
server, err := hap.NewServer(fs, a.A)
if err != nil {
// stop if an error happens
log.Panic(err)
}
// Setup a listener for interrupts and SIGTERM signals
// to stop the server.
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt)
signal.Notify(c, syscall.SIGTERM)
ctx, cancel := context.WithCancel(context.Background())
go func() {
<-c
// Stop delivering signals.
signal.Stop(c)
// Cancel the context to stop the server.
cancel()
}()
// Run the server.
server.ListenAndServe(ctx)
}
I'm still confused on why
s.ifaceIPs
is nil only on Windows? Doesn't make any sense!I haven't added any code yet, just use the example code
package main import ( "github.com/brutella/hap" "github.com/brutella/hap/accessory" "context" "log" "os" "os/signal" "syscall" ) func main() { // Create the switch accessory. a := accessory.NewSwitch(accessory.Info{ Name: "Lamp", }) // Store the data in the "./db" directory. fs := hap.NewFsStore("./db") // Create the hap server. server, err := hap.NewServer(fs, a.A) if err != nil { // stop if an error happens log.Panic(err) } // Setup a listener for interrupts and SIGTERM signals // to stop the server. c := make(chan os.Signal) signal.Notify(c, os.Interrupt) signal.Notify(c, syscall.SIGTERM) ctx, cancel := context.WithCancel(context.Background()) go func() { <-c // Stop delivering signals. signal.Stop(c) // Cancel the context to stop the server. cancel() }() // Run the server. server.ListenAndServe(ctx) }
@brutella @zuozhehao This might have something to do with IPv6.
https://github.com/brutella/dnssd/blob/master/mdns.go#L146
I think it should be caused here.
https://github.com/brutella/dnssd/blob/master/mdns.go#L220
it's error message read udp4 0.0.0.0:5353: use of closed network connection
@brutella
Same question https://github.com/brutella/hc/issues/201