add high level client/server sync controller

This commit is contained in:
Ben Grewell
2021-04-05 10:56:03 -07:00
parent ff56a74e50
commit d52d741a4b
6 changed files with 294 additions and 25 deletions

39
tests/controller/main.go Normal file
View File

@@ -0,0 +1,39 @@
package main
import (
"fmt"
"github.com/BGrewell/go-iperf"
"log"
)
func main() {
// First create a controller for the "client" side (would be on a different computer)
cc, err := iperf.NewController(6802)
if err != nil {
log.Fatal(err)
}
cc.Port = 6801 //Note: this is just a hack because we start a listener on the port when we get a new controller and in this case since we are on the same pc we would have a port conflict so we start our listener on the port+1 and then fix that after the listener has started since we won't use it anyway
// Second create a controller for the "server" side (again would normally be on a different computer)
sc, err := iperf.NewController(6801)
if err != nil {
log.Fatal(err)
}
fmt.Printf("[+] Server side controller listening on %d\n", sc.Port)
// Test iperf
iperfCli, err := cc.NewClient("127.0.0.1")
if err != nil {
log.Fatal(err)
}
err = iperfCli.Start()
if err != nil {
log.Fatal(err)
}
<- iperfCli.Done
fmt.Println(iperfCli.Report().String())
}