http://www.cnblogs.com/leoncfor/p/5009263.html //go-tcpsock/server.go func handleConn(c net.Conn) { defer c.Close() // read from the connection b := make([]byte, 512) for { length, err := con.Read(b) if err != nil { f.Println("1 connection closed ") break } if b != nil {...} } // write to the connection //... ... } func main() { l, err := net.Listen("tcp", ":8888") if err != nil { fmt.Println("listen error:", err) return } for { c, err := l.Accept() if err != nil { fmt.Println("accept error:", err) break } // start a new goroutine to handle // the new connection. go handleConn(c) } } 用户层眼中看到的goroutine中的“block socket”,实际上是通过Go runtime中的netpoller通过Non-block socket + I/O多路复用机制“模拟”出来的,真实的underlying socket实际上是non-block的,只是runtime拦截了底层socket系统调用的错误码,并通过netpoller和gor...