When/Why can recv() return 0
807578Aug 22 2001 — edited Sep 4 2001I've been reading documents all morning, but I can't seem to find an answer to this one.
When and why can a blocking recv() return 0? (BTW, I'm using Forte 6 C++ Update 1 on Solaris 7 and 8).
Various UNIX programming FAQ's claim a blocking recv() returns 0 if the connection is closed indicating EOF. But this is not directly stated in the man pages for recv(). The way I read the man pages, is recv() would return -1 with an appropriate errno if the connection was closed. Furthermore, in my code where recv() is returning 0, it doesn't appear as if the connection is closed as a later call to recv() will get data.
So when recv() unblock's returning 0, do I need to retry, or should I catch the zero case?