This is an example of network autoconfiguration with Go / ØMQ. The server sets up a ØMQ REP socket for clients to connect to, and advertises its presence using a multicast publisher socket. Clients listen on the service port using a multicast subscriber socket; once they receive the advertised server address and port, it stops listening for a server and sends a hello world message to the server.
You can fetch the code using
go get bitbucket.org/kisom/gozmq_autoconf
The source code can be pulled from bitbucket with:
hg clone https://bitibucket.org/kisom/gozmq_autoconf
The code can be built and tested using the included mkfile. Alternatively, once fetched:
go build bitbucket.org/kisom/gozmq_autoconf/server go build bitbucket.org/kisom/gozmq_autoconf/client
Both server and client need to have an interface explicitly chosen using the
-i flag. For example,
server/server -i wlan0
Right now, this code has only been tested on Ubuntu 12.10. It might require some finangling on other platforms to make sure the installed ØMQ version matches the Go library's version (version 2.2). It almost certainly will not work on OS X; as of the time of this writing, the EPGM transport isn't supported.