course/networkProgram/TCP/packet_splicing_client.go

29 lines
473 B
Go
Raw Permalink Normal View History

2024-07-10 19:46:50 +08:00
package main
import (
"fmt"
"net"
"course/networkProgram/protocol"
)
// 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)
}
}