From 086a76b6779e18262b19159acf1cbe2fb48aaad4 Mon Sep 17 00:00:00 2001 From: Peter Kleiweg Date: Thu, 25 Mar 2021 11:56:31 +0100 Subject: [PATCH] examples: clonesrv6 typo, ticlient documentation, udpping3 bugfix --- examples/clonesrv6.go | 2 +- examples/intface/intface.go | 10 ++++++---- examples/ticlient.go | 6 ++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/examples/clonesrv6.go b/examples/clonesrv6.go index b3a0f3c..3a346fe 100644 --- a/examples/clonesrv6.go +++ b/examples/clonesrv6.go @@ -69,7 +69,7 @@ func main() { srv.peer = 5556 srv.primary = false } else { - fmt.Println("Usage: clonesrv4 { -p | -b }") + fmt.Println("Usage: clonesrv6 { -p | -b }") return } // Primary server will become first active diff --git a/examples/intface/intface.go b/examples/intface/intface.go index 046bd86..9f90774 100644 --- a/examples/intface/intface.go +++ b/examples/intface/intface.go @@ -106,8 +106,8 @@ type agent_t struct { func new_agent() (agent *agent_t) { // push output from udp into zmq socket - bcast := &net.UDPAddr{Port: PING_PORT_NUMBER, IP: net.IPv4bcast} - conn, e := net.ListenUDP("udp", bcast) + addr := &net.UDPAddr{Port: PING_PORT_NUMBER, IP: net.IPv4allsys} + conn, e := net.ListenMulticastUDP("udp", nil, addr) if e != nil { panic(e) } @@ -139,6 +139,8 @@ func new_agent() (agent *agent_t) { peers: make(map[string]*peer_t), } + pipe.SendMessage("AGENT ", uuID.String()) + return } @@ -177,7 +179,7 @@ func (agent *agent_t) handle_beacon() (err error) { uuid_bytes := []byte(msg[0]) if bytes.Compare(uuid_bytes, agent.uuid_bytes) != 0 { // Find or create peer via its UUID string - uuID, _ := uuid.ParseBytes(uuid_bytes) + uuID, _ := uuid.FromBytes(uuid_bytes) uuid_string := uuID.String() peer, ok := agent.peers[uuid_string] if !ok { @@ -199,7 +201,7 @@ func (agent *agent_t) handle_beacon() (err error) { func (agent *agent_t) reap_peer(peer *peer_t) { if time.Now().After(peer.expires_at) { // Report peer left the network - agent.pipe.SendMessage("LEFT", peer.uuid_string) + agent.pipe.SendMessage("LEFT ", peer.uuid_string) delete(agent.peers, peer.uuid_string) } } diff --git a/examples/ticlient.go b/examples/ticlient.go index 4c15e7e..6390e61 100644 --- a/examples/ticlient.go +++ b/examples/ticlient.go @@ -2,6 +2,12 @@ // Titanic client example. // Implements client side of http://rfc.zeromq.org/spec:9 +// To use this example: +// 1. start mdbroker +// 2. start mdworker +// 3. start titanic +// 4. run ticlient + package main import (