|
|
||
|---|---|---|
| .. | ||
| examples | ||
| .gitignore | ||
| .travis.yml | ||
| LICENSE | ||
| README.md | ||
| peerdiscovery.go | ||
| peerdiscovery_test.go | ||
peerdiscovery
Pure-go library for cross-platform thread-safe local peer discovery using UDP multicast. I needed to use peer discovery for croc and everything I tried had problems, so I made another one.
Install
Make sure you have Go 1.5+.
go get -u github.com/schollz/peerdiscovery
Usage
The following is a code to find the first peer on the local network and print it out.
discoveries, _ := peerdiscovery.Discover(peerdiscovery.Settings{Limit: 1})
for _, d := range discoveries {
fmt.Printf("discovered '%s'\n", d.Address)
}
Here's the output when running on two computers. (Run these gifs in sync by hitting Ctl + F5).
Computer 1:
Computer 2:
For more examples, see the scanning example or the docs.
Contributing
Pull requests are welcome. Feel free to...
- Revise documentation
- Add new features
- Fix bugs
- Suggest improvements
License
MIT

