Reading from an unresponsive TCP client gives infinite EOF

Written by
Link to Post by 


I’m writing a codebase of which a small part is TCP client server model. So sometimes I’m able to read legit data from the clients and sometimes when the client doesn’t send any data but is connected to the server, and the server is reading from the connection I get a io.EOF which you might know.

But the EOF error comes going for infinity. So is there any way that I can ignore reading from the idle connection and proceed with the other connections or is there any one who can suggest an alternative?

For each client I’m doing this in a go routine.

for {

buf := make([]byte, 1024)

_, err := conn.Read(buf)

if err == io.EOF {

fmt.Println("infinite EOF error.")



Thank you very much.

submitted by /u/iammunukutla
[link] [comments]

Article Tags:
· ·
Article Categories:

Leave a Reply