示例#1
0
文件: mdns.go 项目: Gaboose/go-pubsub
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})
}
示例#2
0
文件: main.go 项目: Gaboose/examples
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
}