I’m implementing a small TCP server. How do I know if one of my clients closed? Should I just try to read or write and check if err is nil?
I’m implementing a small TCP server. How do I know if one of my
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That thread “Best way to reliably detect that a TCP connection is closed“, using
net.Connfor ‘c‘ (also seen inutils/ping.goorlocale-backend/server.goor many other instances):For detecting a timeout, it suggests:
Update 2019: tuxedo25 mentions in the comments:
See commit 5bcdd63 and go issue 15735