Created
September 11, 2014 20:24
-
-
Save lsowen/4f51a27cc58cf56884b4 to your computer and use it in GitHub Desktop.
Example DNS-SD query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"github.com/armon/mdns" | |
"sync" | |
) | |
func channelHandler(wg sync.WaitGroup, ch <-chan mdns.ServiceEntry) { | |
go func() { | |
for entry := range ch { | |
fmt.Println("Entry Found: " , entry) | |
wg.Done() | |
} | |
}() | |
} | |
func main() { | |
entriesCh := make(chan mdns.ServiceEntry) | |
var wg sync.WaitGroup | |
wg.Add(1) | |
channelHandler(wg, entriesCh) | |
mdns.ResolveService(os.Args[1], entriesCh) | |
wg.Wait() | |
close(entriesCh) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment