-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Description
Set Timeout for Accept and AcceptTCP methods in package net. Which compiler are you using (5g, 6g, 8g, gccgo)? 8g Which operating system are you using? Windows 7 Which revision are you using? (hg identify) tip Please provide any additional information below. package main import ( "fmt" "flag" "net" ) var listening bool = true func main() { flag.Parse() address, err := net.ResolveTCPAddr("tcp", ":8080") if err != nil { panic(err) } fmt.Printf("ListenTCP\n") l, err := net.ListenTCP("tcp", address) if err != nil { panic(err) } defer l.Close() for { // this point is unreachable so far that any client to connect if !listening { break } fmt.Printf("AcceptTCP\n") conn, err := l.AcceptTCP() if err != nil { panic(err) } fmt.Printf("conn %s", conn) } }