/** * The MQTT server. Listens for and handles requests between * publishers and subsribers. */ func serve() { l, err := net.Listen("tcp", ":4000") if err != nil { die(err) } svr := mqtt.NewServer(l) svr.Start() <-svr.Done }
//Run the broker func (b *MqttBroker) Run() { l, err := net.Listen("tcp", b.port) gotError(err) svr := mqtt.NewServer(l) svr.Start() <-svr.Done }
// Start the MQTT server. func (w *MQTTServer) Run() { port := getInputOrConfig(w.Port, "MQTT_PORT") listener, err := net.Listen("tcp", port) flow.Check(err) glog.Infoln("mqtt started, port", port) server := mqtt.NewServer(listener) server.Start() w.PortOut.Send(port) <-server.Done glog.Infoln("mqtt done, port", port) }
func main() { flag.Parse() l, err := net.Listen("tcp", *addr) if err != nil { log.Print("listen: ", err) return } svr := mqtt.NewServer(l) svr.Start() <-svr.Done }
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 }
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 }