package main import ( "fmt" "net" ) var connID int func peocessConn(conn net.Conn, connID int) { fmt.Println(" ") var tmp [2000]byte for { _, err := conn.Read(tmp[:]) if err != nil { fmt.Println("read from conn failed", err) return } } } func main() { connID = 0 var connID int listener, err := net.Listen("tcp", "192.168.32.144:20001") if err != nil { fmt.Println("start tcp server 192.168.32.144:20001 failed", err) return } for { conn, err := listener.Accept() if err != nil { fmt.Println("accept failed", err) return } connID = connID + 1 fmt.Println("connID", connID) go peocessConn(conn, connID) } }