naggie / sd01

Minimal service discovery with strict implementation. You should probably use mDNS.
MIT License
6 stars 2 forks source link

Move Go implementation to this repo #4

Closed jimjibone closed 6 years ago

jimjibone commented 6 years ago

Hi @naggie, I have written an implementation of sd01 for Go and it currently lives in woodhouse-v99/sd01. Once I'm happy with its workings and API I'll transfer over to this repo.

I have extended the functionality of sd01 slightly as well. As normally you cannot bind to the same address and port multiple times simultaneously I have implemented a method to allow address and port reuse for unix-like OSes. This sets the SO_REUSEADDR and SO_REUSEPORT socket options and allows for multiple clients to operate on the same machine simultaneously. This took a bit of digging through the CZMQ source to find out how they manage it.

Annoyingly, I haven't managed to implement the same multi-client support for Windows as the Go language is missing implementation for a fairly vital function! Missing net.FilePacketConn() which allows me to take the specially configured socket file descriptor and wrap with a Go PacketConn type.

I suggest we modify the Python implementation to include the SO_REUSEADDR and SO_REUSEPORT socket options (which should hopefully be easily possible in Python).

naggie commented 6 years ago

Excellent, thanks! I've added #5 to use SO_REUSEADDR and SO_REUSEPORT. Will do soon! We can add tests for go later and then I'll probably add some CI with coverage.