-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.FrozenDueToAge
Milestone
Description
by xiezhenye:
sample of net.Conn.Accept: ln, err := net.Listen("tcp", ":8080") if err != nil { // handle error } for { conn, err := ln.Accept() if err != nil { // handle error continue } go handleConnection(conn) } When err that Accept returns is not nil, it must not continue the loop. recoverable err like syscall.EAGAIN, syscall.ECONNABORTED has been handler in Accept, and all the err that returned is not recoverable. continue the loop will cause dead loop. the sample should be: ln, err := net.Listen("tcp", ":8080") if err != nil { // handle error } for { conn, err := ln.Accept() if err != nil { // handle error break } go handleConnection(conn) }
Metadata
Metadata
Assignees
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.FrozenDueToAge