I\'m trying to avoid TIME_WAIT in a client. I connect and then set O_NONBLOCK and SO_REUSEADDR. I call read until it returns 0. When read returns 0, the errno is also 0.
Later on the same page they mention SO_REUSEADDR. That's what you need. You definitely want to close the read file descriptor when it returns zero.