Problem using ReadFromUDP on Windows to discover local peers

67 views
Skip to first unread message

zack....@gmail.com

unread,
Apr 23, 2018, 3:07:07 AM4/23/18
to golang-nuts

I wrote a library (schollz/peerdiscovery) for discovering peers on a local network. I've tested it between a wireless ubuntu laptop and a wired ubuntu server and it works great.


Basically you can run the following on computer 1 and computer 2:


go get github.com/schollz/peerdiscovery
cd $GOPATH/src/github.com/schollz/peerdiscovery/examples
go run broadcast.go


After both are run, both computers will discover each other and the associated payload (in the example its a random payload), and they will output something like:


2018/04/22 23:59:11 discovered ip '192.168.XX.XX' with payload 'YY'


But...this doesn't work on Windows! I have no idea why. If one of the computers is a Windows computer there is no activity, and no errors. I put in logging and found that Windows will get to the ReadFromUDP(buffer) and then it is unable to read anything, ever and its sent packets aren't reaching the other computers.


Is this a Windows firewall issue? Or something else? I'd love to hear any advice, thanks! For the record, I'm using go1.10 on all computers.

zack....@gmail.com

unread,
Apr 24, 2018, 12:25:44 AM4/24/18
to golang-nuts
I got it working! Got it working with golang.org/x/net/ipv4, for some reason the pkg/net ReadFromUDP just didn't work.
Reply all
Reply to author
Forward
0 new messages