func main() {
l, err := net.Listen("tcp", ":8095")
if err != nil {
log.Fatal(err)
}
defer func(l net.Listener) {
err := l.Close()
if err != nil {
}
}(l)
fmt.Println("init success ........")
for {
conn, err := l.Accept()
if err != nil {
log.Fatal(err)
}
//go handleMsg(conn)
buff := make([]byte, 1024)
msg := ""
for {
n, err := conn.Read(buff)
if err != nil {
return
}
s := string(buff[:n])
msg = msg + s
// msg = msg+string(buff[:n])
//fmt.Print(string(buff[:n]))
}
}
}
更多评论
![iShot2021-12-23 09.58.05.png](https://static.studygolang.com/211223/9890f9194b579b43f46b27498e2c4aca.png)
#1