There's a func to handle tcp connection:
for {
select {
case conn := <-listen:
go handleClient(conn)
...
}
func handleClient(client net.Conn) {
for {
// ...read from conn
// at some point return
return
}
}
My question is , if you use for
loop, you must write return
or it will be a dead loop. If it returns, this handleClient
function will execute only once. So for
is not necessary here, right? We can still read all of the data Without for
, is this the right way to think ?