func startLoadClient() (port int) { port = start_rtp_port var server *protocols.Server var stats *load.LoadStats for { var err error server, err = protocols.NewServer(net.JoinHostPort(rtp_ip, strconv.Itoa(port)), load.MiniProtocol) if err != nil { log.Printf("Failed to start Load server on port %v: %v", port, err) port += 2 continue } stats, err = load.RegisterServer(server) if err != nil { log.Printf("Failed to register Load server on port %v: %v", port, err) port += 2 continue } if print_load_packets { stats.Handler = func(packet *load.LoadPacket) { packet.PrintReceived() } } break } tasks.AddNamed("client", server) go func() { for err := range server.Errors() { log.Println("Error receiving Load:", err) } }() log.Printf("Listening on %v UDP port %v for Load\n", rtp_ip, port) statistics = append(statistics, stats.Received) statistics = append(statistics, stats.Missed) return }
func printServerErrors(servername string, server *protocols.Server) { for err := range server.Errors() { log.Println(servername + " error: " + err.Error()) } }
func printErrors(server *protocols.Server) { for err := range server.Errors() { log.Println("Server error: " + err.Error()) } }