aa
This commit is contained in:
@@ -20,22 +20,24 @@ func connHandler(c net.Conn) {
|
|||||||
//缓冲
|
//缓冲
|
||||||
buf := make([]byte, 1024)
|
buf := make([]byte, 1024)
|
||||||
fmt.Println("Please input data...")
|
fmt.Println("Please input data...")
|
||||||
for {
|
go func() {
|
||||||
//读取终端输入直到读取到\n
|
for {
|
||||||
//input, err := reader.ReadString('\n')
|
//读取终端输入直到读取到\n
|
||||||
//if err != nil {
|
//input, err := reader.ReadString('\n')
|
||||||
// fmt.Println("ReadString err:", err)
|
//if err != nil {
|
||||||
// return
|
// fmt.Println("ReadString err:", err)
|
||||||
//}
|
// return
|
||||||
//写入数据
|
//}
|
||||||
c.Write([]byte("input 1111111111"))
|
//写入数据
|
||||||
//服务器端返回的数据写入buf
|
c.Write([]byte("input 1111111111"))
|
||||||
cnt, err := c.Read(buf)
|
//服务器端返回的数据写入buf
|
||||||
if err != nil {
|
cnt, err := c.Read(buf)
|
||||||
fmt.Println("Read err:", err)
|
if err != nil {
|
||||||
return
|
fmt.Println("Read err:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//服务器端回传的信息
|
||||||
|
fmt.Println("server response:", string(buf[0:cnt]))
|
||||||
}
|
}
|
||||||
//服务器端回传的信息
|
}()
|
||||||
fmt.Println("server response:", string(buf[0:cnt]))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user