Commit 431d0881 authored by barnettZQG's avatar barnettZQG

change server

parent 1d574ae6
Pipeline #754 canceled with stages
......@@ -9,8 +9,8 @@ import (
)
func main() {
//address := "106.15.152.33:27065"
address := "127.0.0.1:8080"
address := "106.15.152.33:27065"
//address := "127.0.0.1:8080"
udpAddr, err := net.ResolveUDPAddr("udp", address)
con, err := net.DialUDP("udp", nil, udpAddr)
if err != nil {
......@@ -18,7 +18,9 @@ func main() {
}
var n = 0
for {
con.Write([]byte(fmt.Sprintf("hello word %d", n)))
message := fmt.Sprintf("hello word %d", n)
con.Write([]byte(message))
fmt.Printf("send:%s \n", message)
n++
data := make([]byte, 1024)
n, _, err := con.ReadFromUDP(data)
......
......@@ -21,7 +21,7 @@ func udpProcess(conn *net.UDPConn, index int) {
}
str := string(data[:n])
fmt.Println("receive from client, data:" + str)
conn.WriteToUDP([]byte(fmt.Sprintf("receive %d", index)), rAddr)
conn.WriteToUDP([]byte(fmt.Sprintf("server receive: %s", str)), rAddr)
<-limitChan
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment