Ejemplo n.º 1
0
func PublishMDNS(host string, port int) {
	info := fmt.Sprintf("go-pubsub(%s)", host)
	service, _ := mdns.NewMDNSService(host, ServiceTag, "", "", port, nil, []string{info})

	// Create and run the mDNS server, don't shudown
	mdns.NewServer(&mdns.Config{Zone: service})
}
Ejemplo n.º 2
0
func publish(port int, tag string) (*mdns.Server, error) {
	// Setup our service export
	host, _ := os.Hostname()
	// Concatenating host with port allows to discover several instances on the same machine
	host = fmt.Sprintf("%s.%d", host, port)
	info := []string{"My awesome service"}
	service, err := mdns.NewMDNSService(host, tag, "", "", port, nil, info)
	if err != nil {
		return nil, err
	}
	fmt.Printf("just created service %v\n", service)

	// Create the mDNS server, defer shutdown
	server, err := mdns.NewServer(&mdns.Config{Zone: service})
	return server, err
}