Пример #1
0
func main() {
	cfg := &tls.Config{
		Certificates: readCert(),
		NextProtos:   []string{"mqtt"},
	}
	l, err := tls.Listen("tcp", ":8883", cfg)
	if err != nil {
		log.Print("listen: ", err)
		return
	}
	svr := mqtt.NewServer(l)
	svr.Start()
	<-svr.Done
}
Пример #2
0
func main() {
	// see godoc net/http/pprof
	go func() {
		log.Println(http.ListenAndServe("localhost:6060", nil))
	}()

	l, err := net.Listen("tcp", ":1883")
	if err != nil {
		log.Print("listen: ", err)
		return
	}
	svr := mqtt.NewServer(l)
	svr.Start()
	<-svr.Done
}