2024-07-10 19:46:50 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net"
|
|
|
|
|
|
|
|
"course/networkProgram/protocol"
|
|
|
|
)
|
|
|
|
|
2024-07-15 21:36:11 +08:00
|
|
|
// socket_stick/client/os.args.go
|
2024-07-10 19:46:50 +08:00
|
|
|
|
|
|
|
func main() {
|
|
|
|
conn, err := net.Dial("tcp", "127.0.0.1:30000")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("dial failed, err", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
defer conn.Close()
|
|
|
|
for i := 0; i < 20; i++ {
|
|
|
|
msg := `Hello, Hello. How are you?`
|
|
|
|
b, err := proto.Encode(msg)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("encode failed, err", err)
|
|
|
|
}
|
|
|
|
conn.Write(b)
|
|
|
|
//time.Sleep(1 * time.Second)
|
|
|
|
}
|
|
|
|
}
|