re: Concurrent TCP server in Go VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Hi there, What's the purpose of the final recursive call in handleConnection()? // recursive func to handle io.EOF for random disconnects handleC...
 

It's so that when the connection breaks we can hit the first if statement checking for an err:

if err != nil {
        log.Println("client left..")

And we can output in the terminal that the client left.

Without attempting to .ReadBytes('\n') we can't know if there was an error or not!

code of conduct - report abuse