initial working version
This commit is contained in:
25
cmd/main.go
25
cmd/main.go
@@ -2,13 +2,17 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/BGrewell/go-conversions"
|
||||
"github.com/BGrewell/go-iperf"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
s := iperf.NewServer()
|
||||
c := iperf.NewClient()
|
||||
c := iperf.NewClient("127.0.0.1")
|
||||
includeServer := true
|
||||
c.IncludeServer = &includeServer
|
||||
fmt.Println(s.Id)
|
||||
fmt.Println(c.Id)
|
||||
|
||||
@@ -16,10 +20,27 @@ func main() {
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
for s.Running {
|
||||
|
||||
err = c.Start()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
for c.Running {
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
|
||||
fmt.Println("stopping server")
|
||||
s.Stop()
|
||||
|
||||
fmt.Printf("Client exit code: %d\n", *c.ExitCode)
|
||||
fmt.Printf("Server exit code: %d\n", *s.ExitCode)
|
||||
iperf.Cleanup()
|
||||
if c.Report.Error != "" {
|
||||
fmt.Println(c.Report.Error)
|
||||
} else {
|
||||
fmt.Printf("Recv Rate: %s\n", conversions.IntBitRateToString(int64(c.Report.End.SumReceived.BitsPerSecond)))
|
||||
fmt.Printf("Send Rate: %s\n", conversions.IntBitRateToString(int64(c.Report.End.SumSent.BitsPerSecond)))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user