Rename mc -> beacon

This commit is contained in:
Jakob Borg
2014-05-15 00:29:18 -03:00
parent 3e34fc66e6
commit adbd0b1834
4 changed files with 7 additions and 7 deletions

34
beacon/cmd/mctest/main.go Normal file
View File

@@ -0,0 +1,34 @@
package main
import (
"encoding/binary"
"log"
"time"
"github.com/calmh/syncthing/mc"
)
func main() {
b, err := mc.NewBeacon(21025)
if err != nil {
log.Fatal(err)
}
go func() {
for {
bs, addr := b.Recv()
log.Printf("Received %d bytes from %s: %x %x", len(bs), addr, bs[:8], bs[8:])
}
}()
go func() {
bs := [16]byte{}
binary.BigEndian.PutUint64(bs[:], uint64(time.Now().UnixNano()))
log.Printf("My ID: %x", bs[:8])
for {
binary.BigEndian.PutUint64(bs[8:], uint64(time.Now().UnixNano()))
b.Send(bs[:])
log.Printf("Sent %d bytes", len(bs[:]))
time.Sleep(10 * time.Second)
}
}()
select {}
}