tcpmachine/examples/ping-pong/pp-client/main.go

30 lines
515 B
Go
Raw Permalink Normal View History

package main
import (
2024-10-12 11:32:38 +02:00
"fmt"
"time"
"git.qowevisa.me/Qowevisa/tcpmachine/tcpclient"
)
func main() {
2024-10-12 11:32:38 +02:00
client := tcpclient.CreateClient("127.0.0.1:10000")
go func() {
for {
if client.IsConnected {
break
}
time.Sleep(100 * time.Millisecond)
}
for i := 0; i < 10; i++ {
client.Server.Write([]byte("PING\n"))
time.Sleep(time.Second)
2024-10-12 11:33:12 +02:00
client.ErrorsChannel <- fmt.Errorf("test err")
}
}()
2024-10-12 11:32:38 +02:00
err := client.StartClient()
if err != nil {
fmt.Printf("ERROR: StartClient: %v\n", err)
}
}