Esempio n. 1
0
func handleConn(c net.Conn) {
	var wg sync.WaitGroup
	input := bufio.NewScanner(c)
	for input.Scan() {
		wg.Add(1)
		go func() {
			defer wg.Done()
			echo(c, input.Text(), 1*time.Second)
		}()
		go func() {
			wg.Wait()
			if c, ok := c.(*net.TCPConn); ok {
				c.CloseWrite()
			}
		}()
	}
}