So I am making this tcp server for a game in Go in I have realized that clients get accepted without me even calling Accept()... If you run this example and try to connect to it via telnet or netcat you will realize that you still get accepted...
package main import ( "fmt" "net" ) func main() { serv, err := net.Listen("tcp", "localhost:1200") if err != nil { fmt.Println(err) return } defer serv.Close() // Clients still get accepted, whats the reason? //sock := serv.Accept() fmt.Scanln() } // So we don't exit

Write your reply...

Never miss a post from Aditya Agrawal, when you sign up for Ednsquare.